Chapter 20

TK Graphics

Beware of programmers who carry screwdrivers.

—Constantinos A. Kotsokalis


A popup menu from tkpopup.py.
Figure 1.
Running tkcascadingmenu.py.
Figure 2.
Running tkscrolledlistbox.py.
Figure 3.
tkpil.py and the Enter New Directory dialog.
Figure 4.
tkpil.py and the Open File dialog.
Figure 5.
Drawing circles with arc objects.
Figure 6.
Stretch the box, stretch the Oval object.
Figure 7.
A Bitmap object.
Figure 8.
An Image object.
Figure 9.
Image and Text objects.
Figure 10.
A Window object (Remember that a button Widget is a Window object too).
Figure 11.

Example Programs

  1. tkpopup.py
  2. tkscrolledlistbox.py
  3. tkpil.py
  4. tkcascadingmenu.py

There are several example programs for chapter 20:  download chapter20.zip.


Download and install the Python Imaging Library, which can be found at http://www.pythonware.com.

Visit the CanvasDemo page:  CanvasDemo.html

Read the article on Virtual World simulation with Python:  http://www.python.org/workshops/1998-11/proceedings/papers/asbahr/asbahr.html.

See the PMW website, at http://pmw.sourceforge.net/.

You can learn more about obfuscated code at:  http://www.ioccc.org/, the home page for the International Obfuscated C Code Contest.  While the emphasis is on C, it is possible to write obfuscated code in any language.  It is more difficult to do in Python, but with the determined application of only average mediocrity anyone can do it.

For information on the GIF format and the controversy surrounding it, see the Burn All Gifs website:  http://burnallgifs.org/.  Eric S. Raymond has a number of interesting articles at his website, http://www.catb.org/~esr/, some of them having to do with the GIF problem.  He also has a new book out, The Cathedral and the Bazaar, from O’Reilly.

For some information on netpbm, and other graphics formats, visit The Graphics Muse, at http://www.graphics-muse.org/.

A new site that just opened up is The Vaults of Parnassus ( http://www.vex.net/parnassus/ ), by Tim Middleton, wwhich promises to be the best place to locate Python modules.  It’s very well done, and some of the most arcane stuff around is easily tracked down here.  It promises to be the Python equivalent of the CPAN archives, a standardized site for locating Perl modules—a heck of a lot cooler, though.

For information on regular polygons and tilings, visit http://www.scienceu.com/geometry/articles/tiling/.  The definitive book on the subject is Tilings and Patterns, by Branko Grungbaum and G.C. Shephard.  Published by W.H. Freeman, it is now unfortunately (and inexplicably) out of print, but any decent library will have (or be able to get) a copy.

Valid HTML 4.01 Transitional