[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

Naturally, other factors such as documentation and extensions are important when
using a GUI toolkit, too; let’s take a quick look at the story tkinter has to tell on these
fronts as well.


tkinter Documentation


This book explores tkinter fundamentals and most widgets tools, and it should be
enough to get started with substantial GUI development in Python. On the other hand,
it is not an exhaustive reference to the tkinter library or extensions to it. Happily, at
least one book dedicated to using tkinter in Python is now commercially available as I
write this paragraph, and others are on the way (search the Web for details). Besides
books, you can also find tkinter documentation online; a complete set of tkinter man-
uals is currently maintained on the Web at http://www.pythonware.com/library.


In addition, because the underlying Tk toolkit used by tkinter is also a de facto standard
in the open source scripting community at large, other documentation sources apply.
For instance, because Tk has also been adopted by the Tcl and Perl programming lan-
guages, Tk-oriented books and documentation written for both of these are directly
applicable to Python/tkinter as well (albeit, with some syntactic mapping).


Frankly, I learned tkinter by studying Tcl/Tk texts and references—just replace Tcl
strings with Python objects and you have additional reference libraries at your disposal
(see Table 7-2, the Tk-to-tkinter conversion guide, at the end of this chapter for help
reading Tk documentation). For instance, the book Tcl/Tk Pocket Reference (O’Reilly)
can serve as a nice supplement to the tkinter tutorial material in this part of the book.
Moreover, since Tk concepts are familiar to a large body of programmers, Tk support
is also readily available on the Net.


After you’ve learned the basics, examples can help, too. You can find tkinter demo
programs, besides those you’ll study in this book, at various locations around the Web.
Python itself includes a set of demo programs in the Demos\tkinter subdirectory of its
source distribution package. The IDLE development GUI mentioned in the next section
makes for an interesting code read as well.


tkinter Extensions


Because tkinter is so widely used, programmers also have access to precoded Python
extensions designed to work with or augment it. Some of these may not yet be available
for Python 3.X as I write this but are expected to be soon. For instance:


Pmw
Python Mega Widgets is an extension toolkit for building high-level compound
widgets in Python using the tkinter module. It extends the tkinter API with a col-
lection of more sophisticated widgets for advanced GUI development and a frame-
work for implementing some of your own. Among the precoded and extensible
megawidgets shipped with the package are notebooks, combo boxes, selection


364 | Chapter 7: Graphical User Interfaces

Free download pdf