O'Reilly Book Excerpts: Python Programming on Win32
Python Programming on Win32 using WxPython
An excerpt from Chapter 20 of O'Reilly's book Python Programming on Win32.
Another GUI toolkit available for Python is called
wxPython. The current incarnation is fairly new to the Python scene and is rapidly gaining popularity amongst Python developers.
wxPython is a Python extension module that encapsulates the wxWindows C++ class library.
wxPython is a cross-platform GUI framework for Python that is quite mature on the Windows platform. It exposes the popular
wxWindows C++ framework Python to provide an attractive alternative for GUI development.
wxWindows is a free C++ framework designed to make cross-platform programming child's play. Well, almost.
wxWindows 2.0 supports Windows 3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version underway. Other ports are under consideration.
wxWindows is a set of libraries that allows C++ applications to compile and run on several different types of computers, with minimal source-code changes. There's one library per supported GUI (such as Motif, or Windows). As well as providing a common API for GUI functionality, it provides functionality for accessing some commonly used operating-system facilities, such as copying or deleting files.
wxWindows is a framework in the sense that it provides a lot of built-in functionality, which the application can use or replace as required, thus saving a great deal of coding effort. Basic data structures such as strings, linked lists, and hash tables are also supplied.
Native versions of controls, common dialogs, and other window types are used on platforms that support them. For other platforms, suitable alternatives are created using
wxWindows itself. For example, on Win32 platforms the native list control is used, but on GTK, a generic list control with similar capabilities was created for use in the
wxWindows class library.
Experienced Windows programmers will feel right at home with the
wxWindows object model. Many of the classes and concepts will be familiar. For example, the Multiple Document Interface, drawing on Device Contexts with GDI objects such as brushes, pens, and so on.
wxWindows + Python = wxPython
wxPython is a Python extension module that provides a set of bindings from the
wxWindows library to the Python language. In other words, the extension module allows Python programers to create instances of
wxWindows classes and to invoke methods of those classes.
More from this Chapter:
wxPython extension module attempts to mirror the class hierarchy of
wxWindows as closely as possible. This means that there is a
wxFrame class in
wxPython that looks, smells, tastes, and acts almost the same as the
wxFrame class in the C++ version.
wxPython is close enough to the C++ version that the majority of the
wxPython documentation is actually annotations to the C++ documentation that describe the places where
wxPython is different. There is also a series of sample programs included, and a series of documentation pages that assist the programmer in getting started with