Online python tkinter simulator: 3 games to help you create python GUIs

I made create.withcode.uk to let teachers and students write, run, debug and share python code online a few years ago in order to try to make it easier for students to experiment with code on any device.

Because create.withcode.uk runs python code in your web browser, you don’t need to install any software or download the code before you run it. You just press Ctrl + Enter to run the whole code, or Ctrl + Space to run it line by line.

This makes it much easier to try out code, tweak it and share it as you’re learning, but it’s only a simulation Python: it doesn’t contain all of the features of Python 3 running offline.

One feature that teachers and students have often requested is Tkinter support.

Tkinter is the GUI (Graphical User Interface) module that comes bundled with python. It lets you create programs that have buttons, text boxes and windows rather than just a text console.

I’m in the process of adding some Tkinter support for create.withcode.uk. It’s a work in progress but I’ve implemented enough for you to get some simple GUI programs working.

There are some great website for running python code online such as trinket.io and repl.it. As far as I know, create.withcode.uk is the only one to have an online python tkinter simulator so that you can test out code to build GUIs in your browser.

Here are some of the programs I’ve been using to test out python tkinter GUI support on create.withcode.uk:

Snake game: Online python tkinter simulator
Game 1: Snake in python tkinter
Bounce game: Online python tkinter simulator
Game 2: Bounce in tkinter
Colour Quiz: Online python tkinter simulator
Game 3: Colour Quiz in tkinter

Note:

These games are examples I’m using to test tkinter support on create.withcode.uk. I didn’t write them: the original authors are credited for each game in the source code and description. Please get in touch if you created these and want me to change the way I’ve attributed your work.

Tkinter isn’t really designed for making games – it’s useful for simple GUIs but there are better python modules out there for creating games (such as pygame). You can find some great books and resources here if you’re interested: https://inventwithpython.com/

Tkinter is a huge module so there’s no way I can simulate it all accurately in a web browser but if you have some code that works offline in ‘proper’ python that doesn’t yet work properly on create.withcode.uk, please share a link to it as a comment on this page and I can use it to help add more features and support.

Have fun!

Create.withcode.uk’s python data visualisation module now available offline

Some of the most popular resources on create.withcode.uk are the bitmap image challenges, which help students see how black and white or full colour images can be represented by 2D or 3D lists of data describing the colour of each pixel.

Data representation of images: Bitmap images
Python data visualisation of images: Bitmap images

A few people have asked if it’d be possible to have an offline version of the withcode python module that is supported by create.withcode.uk which allows you to quickly display a list of data as an image.

This could be useful for lessons or clubs where an Internet connection isn’t available or for use in other python projects.

You can now download a copy of withcode.py from https://github.com/pddring/withcode-py-offline and use it in IDLE / Mu / your favourite python IDE so that your code works in the same way as it would on create.withcode.uk

5 Life Lessons Young People Can Learn From Programming

5 Life Lessons Young People Can Learn From Programming
5 Life Lessons Young People Can Learn From Programming. Image source: PIXNIO

This article has been written by Kayleigh Alexandra from microstartups.org

microstartups.org: Giving through growth hacking

With the trend towards ever-greater automation, it’s becoming abundantly clear that the development of rich digital skills is increasingly important for new generations. That’s a good enough reason in itself to encourage young people to get involved with programming, but as they get stuck into software development they’ll no doubt encounter a treasure trove of life lessons with lasting consequences on their character as well as their future career.

In particular, there are 5 invaluable life lessons that immersion into the coding world can rapidly drill into a young person’s mind, ultimately helping them live happier and more successful lives — so let’s take a look at them, and consider why they’re so important.

Being self-driven is tough but vital

For anyone used to being given specific direction when learning a new skill (read this textbook front to back, answer these questions, and you’ll get a certificate), starting out with programming can be quite the wake-up call — it all owes to the essential spirit of experimentation and DIY.

Want to create a specific type of application? You’ll surely be able to find forums full of people who’ll give you pointers, but they won’t hold your hand and give you the answers. They’ll help you to find the answers for yourself, because self-management is a vital skill to develop.

As I type this, there are programmers across the world diligently updating their skills and poring over documentation, and they’re far too busy to lead you. The sooner you learn that you’re the only person who can solve your problems, the sooner you’ll realise how empowering and satisfying that is — no matter what you’re trying to achieve.

You need to use all available resources

Creativity and originality are rightly highly revered. Stealing other people’s ideas through outright plagiarism is an awful thing to do, and our egos drive us to achieve using our ideas as opposed to anyone else’s. But there’s a slight problem with that: originality isn’t really that original. It stems from our brains collating inspiration and making some minor tweaks. No inspiration, no breakthrough.

Programming imparts this wisdom very quickly through libraries. It’s a time-intensive industry, and there’s zero practical benefit in writing a chunk of code from scratch if you can find and repurpose established code for free — you may need to provide attribution, but that’s completely normal. It’s a very collaborative field.

An important lesson to learn is that the desire to be original and solitary can drive people to waste time on things that don’t ultimately matter. This is something that the ecommerce industry understands well. Merchants speed up anything non-essential (using freelancers for copy, buying websites instead of building them, conducting widespread competitor research, etc.), because part of being self-driven and empowered is knowing when there’s no sense in starting with a blank slate.

Small actions can have big consequences

One keystroke goes awry during a late-night coding session, it doesn’t get caught in review, and six weeks later a giant network goes down, staying down for days before someone identifies the root cause. Anyone who has ever thought “Well, it’s just a minor mistake, there’s no way it will ultimately matter” would get quite a shock from trying programming.

But there’s another interpretation of this that’s significantly more positive. Programming is something to be learned incrementally, with knowledge gradually spanning languages, topics and platforms, and that can be intimidating to someone new to it — but the concept of tiny steps gathering into a lengthy journey is key to long-term contentment.

You can’t learn Python in a day, but you can learn something about it, and build on it in the next lesson. Want to get healthier? Eat better today, and tomorrow, and the day after, going one day at a time, and soon enough you’ll be feeling better. Any goal you want to achieve should be targeted in the same way.

It isn’t hard work when you’re passionate

If you’ve ever heard some version of this statement said, you’ll know what I’m getting at. Programming is not something that immediately appeals to everyone. You can certainly understand why some might look at it and conclude that it’s an arduous, frustrating and repetitive war of attrition.

Here’s the thing: it’s a matter of perspective, and only when you find yourself researching a specific function in the early hours of the morning do you fully understand that anything — not matter how reductively you choose to define it — can be enjoyable and rewarding if you’re passionate about it.

Never forget this, or that tastes naturally change and develop over time. That way, you won’t judge things by how they sound but by how they feel to you (different people like different things). One day, you may even realise (to your surprise) that you’re one of the workaholics you always thought to be miserable, but working so vigorously because you want to.

Flexibility is a remarkable strength

Anyone who claims to know everything there is to know about programming is a liar and a charlatan, because there’s far, far too much out there for any one person to know it all. Countless languages, standards, practices, libraries, templates, and operational models — and each one subject to change on a daily basis.

And as nice as it sounds to pick up a specific set of skills and then profit from it for the rest of your life, that’s not how things work in the coding world. Every professional is expected to keep up with the latest developments, and periodically abandon large chunks of their knowledge to suit broad industry changes. Specific programming knowledge is vastly less important than the ability to obtain it as and when needed.

This is a momentous life lesson to learn because it essentially reassures people of two things: firstly, that they will never stop learning, and secondly, that they will keep getting better. The human ability to acquire new skills lasts about as long as we do, and the more you embrace your adaptability, the better you’ll fare.