HOME Python download Post Messages

A demo of Tkinter

1. Introduction

Tkinter is one of the most popular GUI tools working on Python. Tkinter and wxPython are most popular and they have their own advantages and disadvantages. Generally speaking, Tkinter is consistent and makes your code shorter. On the other hand, you may need wxPython to make a complicated GUI.

Tkinter is a wrapper of Tcl/Tk as the name implies. Tcl/Tk is a pioneering work of OS independent GUI and widely used nowadays. You should learn Tk first, I think, even if you are rather interested in other GUI tools.

When you download Tcl/Tk, the reference manual and the demo scripts are included, which make easy to learn the tool. In addition, you can find a lot of resources about Tcl/Tk on the web. On the contrary, little resources about Tkinter are available on the web. There is almost no demo script of Tkinter.

Even Tk is extremely convenient, I (and many people) don't like Tcl which is a script language that control Tk. For this, Tk has been ported into popular programming languages, such as Perl, Python, Ruby, and Scheme.

Even Tkinter is substantially different from Tcl/Tk, no reference manual was available, which makes it difficult to use Tkinter. Now, some manuals are available on the web and a book has been published, by which Tkinter programming is getting easier.

On the other hand, I could find little demos on Tkinter on the web. So, I have translated the demo scripts included in the archive of Tcl/Tk into Tkinter. I enjoyed this process and am convinced that Tkinter is much smarter than Tcl/Tk. I hope the translated demo codes are useful.

2. How to use the translated demo codes

  1. Download Tkinter_demo.zip or Tkinter_demo.tgz and melt it somewhere.
  2. Then go to the directory in that uncompressed files are and execute index.py.
You will see the index of the demos (Fig. 1).

Each demo is executable by itself. For instance, type

>python label.py
from the console if you want to see label.py (Fig. 2).

Fig. 1. Index of the demo.

Fig. 2. Demo of labels.

3. Environment

I have checked that the script works in the following environment. I hope my script works on other environments. If not, send a message to takafumi@shido.info.

6. Links

I pickup some useful links to learn Tkinter.
  1. Tkinter reference: a GUI for Python, by J. W. Shipman (PDF): Most useful.
  2. An Introduction to Tkinter, by F. Lundh: Also useful.
  3. Tkinter Wiki: Links to Tkinter resources.
  4. http://wiki.python.org/moin/TkInter: Links to Tkinter resources.