home (all)home (en)

To read this page you had better to know a little of computer programming and you should be familiar with Python basics. If you don't, reading is not forbidden, it's just incomprehensible. I hope this text will be helpful, when trying to get started with Python Graphical User Interface.

You can get your own copy of Python from http://www.python.org/. It's just wonderful, what you can get for free nowadays . Note that Python 3 is different and incompatible with old versions of Python 2. This is written according to new Python 3 syntax. The samples are given as .txt files.

You are allowed to copy and study these samples. Modifying and running at your own risk only.


Risto Latva

Python 3 tkinter demos - page 1

One of the first tasks when plunging into a new language is making familiar with the user interface tools. Few end users are willing to use command line parametres. So, the GUI has got to do what a GUI has got to do.

I am not a Python expert. Actually, I am new with Python, but I have been writing programs in Delphi. Tkinter is more frugal, but useful for many purposes. You don't really need hundreds of widgets to communicate with the user. The user can input a limited set of data types only. For names, dates and numbers you can use Entrys. The user can point one item from a given set: use Radiobutton or Listbox in single or browse mode. If the user should select a subset of  a given set, you can use Listbox in multiple or extended mode or a row of Checkboxes. To launch functions you can use Button or Menu. Maybe there are few more data types, but not too many, anyway. So, know your horses profoundly even if you don't have the world's best horses.

Provided that you have read the Simple Hello World Program in tkinter documentation and found it insufficient, py_demo_tk1 goes one step further. It shows how to pack few Edits, Labels and Buttons in a bunch of Frames. To pretend some important processing, it turns your text backwards and squeezes spaces off it, but this is not the point, of course. Besides, keyboard return and esc keys are effective.

The second sample py_demo_tk2 shows how to use Radiobuttons and different selectmodes of Listbox. Try selecting items in different modes using the keyboard only.

The third sample py_demo_tk3 could turn out useful sometimes, when you need to find out, what a keyboard event looks like, when seen from inside the program.



 | next-> (for more samples)

home (all)home (en)