GUI apps with Python

Python

OK … I am learning Python fro months, writting script for this, scripts for that, … but until now, all scripts were with no GUI associated. Now, it’s turn to jump into another level, but …

Pero ha llegado el momento de dar el salto y …

Now I understand why I waited so long in learning Python

Now that I feel confortable with Python, the key now is to create visual apps..

The first step is to understand the graphical libraries (options)available, and there is several waiting to give them a try: https://wiki.python.org/moin/GuiProgramming.

  • Tkinter, is the default library with Python, it doesn’t seem very nice, but … it works on all platforms. No installation required.
  • PyQt, seems more attractive, but you need to install it, and also, you have to pay, although you have the project PySide , almost the same but open licence.
  • wxWidgets, is also beautiful, it requires you to install it, and you can use it with other languages appart from Python, such as Ruby or Perl.

there are more, but the three above are the most used with Python. By now, I have started to learn Tkinter, so the rest of the post will be referred to Tkinter.

Tkinter

It’s the Python default GUI library, included with the Python distribution. I really like that it’s very fast to learn. I’ve been watching some YouTube videos about this library, and … it seems easy to program with: instructions are simple, and all is based on a bunch of widgets ready for you to use!

If you need a tutorial of Tkinter, start with this one:: http://www.tkdocs.com/tutorial/index.html

Creating visual apps with Tkinter

The big problem with the libraries available for Python is that there are a few tools for creating form visually, as I did when Visual Studio and VB6. No one has visual tools, and all (libraries) are based on code.

But, even if you need to code the form, I would guess … is there any tool that help you in developing RAD apps?. Here are a few tool I tried.

Rapid-TK, is the first tool I try. The interface is not very “good-looking”, and it’s not wysisyg.

rapyd-TK

rapyd-TK

You can see the “simulated form”, but to see the real result, you need to create, compile and run the code generated. The outcome for the previous image (a calculator) is this:

ejemplo de rapyd-TK

Test with rapyd-TK

The second tool I tried is Visual Tkinter Python, with a better looking that the previous one. I think this tool is programmed using .NET (becuase of the aspect, but i’m not sure!). I tries a Beta version, an inmature tool, and not all widgets are available. So, for complicated forms, you will need to code manually. You can have an approach of the form you’re creating….

Visual Tkinter Python

Visual Tkinter Python

After a more deep testing, the tool is inmature, and it could be better to wait for a non-beta version.

Visual Tkinter for Python

The third tool I tried is, by now and in my opinion, the best alternative, Visual Tkinter for Python, an Add-In for Visual Basic 6 (yes, you’ve read correctly, a Visual Basic 6 add-in!!). you can create your forms using Visual Studio 6 the same way as you create your VB6 forms, you start the tool, and you can get the Python’s code.

Let’s try it works with a project already described here called From Quotes to Percentages, a few months ago under Visual Basic 6. The form created was this:

De Cuotas a Porcentajes version 4

De Cuotas a Porcentajes version 4

Let’s load the form on the Visual Tkinter for Python tool:

Probando Visual Tkinter Python

trying Visual Tkinter Python

the Python code generated is available on GitHub, and the next image is the Python’s form (warning!! functionality is not implementes, just the code of the form)!

Probando Visual Tkinter for Python en VB6

Trying Visual Tkinter for Python

Of course, I would like to thank its creator for fixing a bug I found!

To end with …

Now, it come back the question of what made me not to start Python programming a few years ago (I was used to program with VB6), and it was the lack of a good IDE to create RAD apps. Of course, I have done several improvements with Tkinter as you can read how to work with modal forms, or the odyssey of working with Tkinter comboboxes. As you can magine, it will be very useful for the future to learn about Python’s frameworks ….

Have a nice day, and let me know your IDE tool for Python’s GUI development!