Getting started with wxPython

We're going to start by working on a real wxPython program, albeit a simple one. We won't create anything complicated, yet. For now, we're going to lead you step-by-step through the process of creating your very first wxPython program. Let's begin by making sure you've got everything installed. Table 1.1 shows everything you'll need in order to run wxPython.

Once the installations are complete, get ready to type. We're going to create a program that displays a single image file. This will happen in three steps:

1 We'll start with the bare minimum required for a working wxPython program.

2 We'll make that code more structured and sophisticated.

3 We'll end with a version that can display the wxPython logo.

Table 1.1 Everything you'll need to run wxPython on your own computer

Tool

Notes

The right operating system

This is an easy one—you have a lot of options. Specifically, you must be running one of the following:

• Any Microsoft Windows 32-bit operating system—meaning anything from Windows 98 onward (and you can get it going under Windows 95 if you must, but you'll need to download some extras).

• Any Unix or Linux system capable of running the Gnome Toolkit (GTK).

• A Macintosh running Mac OS X 10.2.3 or higher.

The Python programming language

Available for download at www.python.org. Any version 2.3 or higher will work. Many Linux distributions include a version of Python, as does Mac OS X 10.3 or higher. Even so, you might still want to download the latest version.

The wxPython Toolkit

Available for download at www.wxpython.org.

There are different versions, depending on your operating system and Python version. Be sure to download the runtime installer that matches your platform, Python version, and Unicode preference. Download the packages for the demos and documentation as well.

If you've installed other software on your system, you should find that installing the wxPython packages works very similarly. Again, recent versions of Mac OS X and some Linux distributions already include wxPython, but you should download the latest version if you can.

A text editor

We recommend an editor that recognizes Python syntax and can do things like colorize the code to make it more readable. Most of the popular editors have support for Python code, so use the editor you prefer.

If you have no strong feelings for any particular editor, try IDLE, the integrated development environment included with Python, which includes a source code editor, interactive shell, debugger, and other tools.

The Python web site has a list of Python-aware editors at www.python.org/editors.

Figures 1.2, 1.3, and 1.4 illustrate what the final program will look like, depending on your platform.

Figure 1.2 Running hello.py on Windows
Figure 1.3 Running hello.py on Linux

Figure 1.4 Running hello.py on Mac OS X

Was this article helpful?

0 0

Post a comment