Chapter 19

TK Widgets II

The Trans Am was ten, with the dents and glitches to prove it, but it still hugged corners like a python.

—Sara Paretsky, in Hard Time


Radio buttons.
Figure 1.
UNIX radio buttons.
Figure 2.
Un-radio button radio buttons.
Figure 3.
Scale widget.
Figure 4.
Scale widget.
Figure 5.
Figure 6.
Text widget.
Figure 7.
Figure 8.
A ScrolledText widget.
Figure 9.
Running tkeditor.py.
Figure 10.
Multiple Toplevel widgets from tktoplevel.py.
Figure 11.
The multiple-window editor running.
Figure 12.

Example Programs

There are several example programs for chapter 19:  download chapter19.zip.

  1. tkradiobutton.py
  2. tkscale.py
  3. tkscale3.py
  4. tkeditor.py
  5. tkscale2.py
  6. tkscrollbar.py
  7. tktoplevel.py
  8. tktext.py
  9. multi-editor.py
  10. tkmiles.py


Visit the K Desktop Environment’s home page, at http://www.kde.org/; visit the GNOME Developer’s site, at http://developer.gnome.org/.

A pleasant way to learn a little about gosh numbers is to read Fred Pohl’s Heechee books, beginning with Gateway.  There are six books altogether.

I won’t tell you in which book gosh numbers first appear.  If you wish to start in strict chronological order, the first story is “The Merchants of Venus”, in The Gateway Trip (a collection of stories).  

There is a small bug in our implementation of tkeditor.py:  when a file is saved, an additional blank line may appear at the end of the saved version.  Find the bug and fix it.

Add more features to tkeditor.py.  Here is the beginning of a list; you can add to it as you see fit:

Valid HTML 4.01 Transitional