October 28, 2016
Hot Topics:

What Can wxPython Do?

  • August 25, 2006
  • By Noel Rappin and Robin Dunn
  • Send Email »
  • More Articles »

Nearly all of your interface needs can be filled by wxPython. In this section, we'll show you what some of the wxPython toolkit looks like, using pictures from elements of the wxPython demo application. Figure 1 is a composite image showing all the basic widgets you'd expect: buttons, checkboxes, a combo box, menus, list box, a spinner control, text controls and radio buttons.

Figure 2 shows less common, but very useful widgets, including a slider control, an editable list box, a time selector, a toolbar, a notebook control, a tree list control, and an analog clock.

The grid control is one of wxPython's most flexible widgets, allowing custom rendering and editing of cells. Figure 3 shows an example of many of the features of the grid control.

And that's not all-you also get a quite fully featured HTML-rendering widget that you can use for static styled text, as the base of a simple web browser, as a help system, or anything else you might want to display HTML for. An example is shown in figure 4.

We've only just scratched the surface. The wxPython library also includes tools for image animation. You also get clipboard and drag-and-drop support, support

Figure 1. A sampling of basic user interface controls, including menus, list boxes, and text controls.

Figure 2. More advanced interface controls, including a tree list and an analog clock.

Figure 3. The mega-grid example, showing custom grid cell rendering.

Figure 4. The wx.HTMLWindow, showing some of the HTML rendering capability.

for MIME types and audio, all the standard dialogs offered by your system, the ability to specify an interface definition in an XML file, full control over the layout of your windows, and more.

Why choose wxPython?

The most powerful benefit of wxPython depends on your needs and expertise. While we think that all user interface (UI) programmers would benefit from using wxPython, the specific features that are most helpful will vary from case to case.

Python programmers

If you are already a Python programmer, you've probably noticed that Tkinter, the interface toolkit distributed with Python, has some problems:

  • Tkinter is based on the Tk toolkit, which is somewhat out-of-date in terms of the kinds of widgets it supports. By default, it doesn't support more complex widgets such as tree controls or tabbed windows. It also doesn't have a particularly rich set of predefined dialogs.
  • The Tk toolkit does not use native widget support, resulting in an application that looks foreign on all platforms. In wxPython, dialogs and widgets will look like those that are standard on the underlying operating system. Your Tk user will find that buttons, fonts, and menus all look slightly different from what might be expected.
  • Many programmers find Tkinter itself somewhat clunky to work with. In particular, the process by which events are translated to actions in wxPython is more flexible and powerful.

You'll find that wxPython solves these problems. The toolkit in wxPython is vastly more complete and extensive than that of Tkinter and the native widget support means your application will look at home in your operating system. Additionally, the Python language support is more fluid in wxPython, making for a somewhat nicer programming experience.

wxWidget users

If you are already using wxWidgets, then what wxPython has to offer you is the Python language itself. With its clear syntax, dynamic typing, and flexible object model, Python can improve your productivity dramatically. Python has a very extensive standard library that is easily incorporated into your application, and Python programs tend to be shorter and less error-prone than C++ programs. There are also a number of Python-only additions to the wxWidgets tool set.

New users

If you're not currently using either Python or wxWidgets, you're in for a real treat, since you'll get the benefit of both the extensive toolkit and the Python language. If you are currently working in Java/Swing, you'll probably find wxPython less complex and easier to use, and the Python language significantly less verbose than Java. If you are currently using a single-platform C++ toolkit like the Microsoft Foundation Classes (MFC), then you'll appreciate the cross-platform nature of wxPython. In order to follow the examples in this book, however, some Python familiarity is helpful. If you need to get started on Python itself, try The Quick Python Book, by Daryl Harms and Kenneth McDonald.

In the next section, you'll learn about the component pieces of wxPython: the Python language itself, and the wxWidgets toolkit. You'll also learn about the rationale and implementation of wxPython itself.

Page 1 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel