04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 12 ■ GRAPHICAL USER INTERFACES 271<br />

also maintains a Web page with an extensive list of GUI toolkits for Python (http://phaseit.net/<br />

claird/comp.lang.python/python_GUI.html).<br />

Table 12-1. Some Popular GUI Toolkits Available for Python<br />

Package<br />

Tkinter<br />

wxPython<br />

PythonWin<br />

Java Swing<br />

PyGTK<br />

PyQt<br />

Description<br />

Uses the Tk platform. Readily available. Semistandard.<br />

Based on wxWindows. Increasingly popular.<br />

Windows only. Uses native Windows GUI capabilities.<br />

Jython only. Uses native Java GUI capabilities.<br />

Uses the GTK platform. Especially popular on Linux.<br />

Uses the Qt platform. Especially popular on Linux.<br />

Information about Tkinter and Jython with Swing can be found in the section “But I’d<br />

Rather Use . . .” later in this chapter. For information about PythonWin, PyGTK, and PyQT,<br />

check out the project home pages (see Appendix C).<br />

As you can see, there are plenty of packages to choose from. So which toolkit should you<br />

use? It is largely a matter of taste, although each toolkit has its advantages and drawbacks.<br />

Tkinter is sort of a de facto standard because it has been used in most “official” Python GUI<br />

programs, and it is included as a part of the Windows binary distribution. On UNIX, however,<br />

you have to compile and install it yourself.<br />

Another toolkit that is gaining in popularity is wxPython. This is a mature and feature-rich<br />

toolkit, which also happens to be the favorite of Python’s creator, Guido van Rossum.<br />

Downloading and Installing wxPython<br />

To download wxPython, simply visit the download page, http://wxpython.org/download.php.<br />

This page gives you detailed instructions about which version to download, as well as what<br />

prerequisites the various versions have. If you’re running Windows, you probably want a prebuilt<br />

binary. You can choose between one version with Unicode support and one without; unless<br />

you know you need Unicode, it probably won’t make much of a difference which one you choose.<br />

Make sure you choose the binary that corresponds to your version of Python. A version of<br />

wxPython compiled for Python 2.3 won’t work with Python 2.4, for example.<br />

For Mac OS X, you should again choose the wxPython version that agrees with your Python<br />

version; you might also need to take the OS version into consideration. Again, you may need<br />

to choose between a version with Unicode support and one without; just take your pick. The<br />

download links and associated explanations should make it perfectly clear which version you need.<br />

There are also RPM packages for various Linux distributions. If you’re running a Linux<br />

distribution with RPM, you should at least download the wxPython common and runtime packages;<br />

you probably won’t need the devel package. Again, choose the version corresponding to<br />

your Python version and Linux distribution.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!