Chapter 18

TK Widgets I

Life is much too short to spend time programming in lousy languages.

—Robert Meegan


Windows and widgets
Figure 1.
A button widget
Figure 2.
A canvas widget
Figure 3.
A checkbutton widget
Figure 4.
A checkbutton widget on UNIX
Figure 5.
An entry widget
Figure 6.
A frame widget
Figure 7.
A label widget
Figure 8.
A listbox widget
Figure 9.
A menu bar
Figure 10.
A cascade menu
Figure 11.
An option menu
Figure 12.
An Info MessageBox widget
Figure 13.
A Warning MessageBox widget
Figure 14.
An Error MessageBox widget
Figure 15.
A Yesno MessageBox widget
Figure 16.
An Okcancel MessageBox widget
Figure 17.
A Retrycancel MessageBox widget
Figure 18.
A Question MessageBox widget
Figure 19.

Example Programs

There are several example programs for chapter 18:  download chapter18.zip.

  1. tkbutton.py
  2. tkcanvas.py
  3. tkcheckbutton.py
  4. tkentry.py
  5. tkframe.py
  6. tklabel.py
  7. tklistbox.py
  8. tkmenu.py
  9. tkmessage.askokcancel.py
  10. tkmessage.askquestion.py
  11. tkmessage.askretrycancel.py
  12. tkmessage.askyesno.py
  13. tkmessage.error.py
  14. tkmessage.info.py
  15. tkmessage.warning.py
  16. tkoptionmenu.py
  17. tkt3.py


Reference pages for the Tkinter widgets, by Fredrik Lundh, can be found at Pythonware.com. Buy his book:

Python Megawidgets can be found at http://pmw.sourceforge.net/.

Take out Alien Abduction Life Insurance, in case you get kidnapped by the Heechee.  Make Scott Meyers the beneficiary.  Get abducted.  Try to file a claim.

Research the history of GUI programming; an excellent starting point is Michael S. Hoffman’s interesting web page, The Unix GUI Manifesto, to be found at http://www.hypertextnavigation.com/unixgui.htm.

Valid HTML 4.01 Transitional