wxPython

wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily.

_images/central_bar.png

What is wxPython

wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module (native code) that wraps the popular wxWidgets cross platform GUI library, which is written in C++.

Like Python and wxWidgets, wxPython is Open Source which means that it is free for anyone to use and the source code is available for anyone to look at and modify. Or anyone can contribute fixes or enhancements to the project.

wxPython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification. Currently supported platforms are 32-bit Microsoft Windows, most Unix or unix-like systems, and Macintosh OS X+, in most cases the native widgets are used on each platform.

Since the language is Python, wxPython programs are simple, easy to write and easy to understand.

As an example, this is a simple “Hello World” program with wxPython:

import wx

app = wx.PySimpleApp()

frame = wx.Frame(None, -1, "Hello World")
frame.Show()

app.MainLoop()

The GUI layouts you can build with wxPython are almost infinite: it has an extremely rich set of widgets (derived from wxWidgets) and greatly extended by a huge set of pure-Python controls written over the years.

Prerequisites

Like any other complex piece of software, wxPython requires other software in order to function properly. Obviously you’ll need Python itself, but if you’re reading this you’ve probably already got Python and are just here looking for the best GUI toolkit available for Python. Check out the details for your platform of choice here:

Win32

  • If you have a modern up to date version of Windows and use the binary installer for wxPython found below, you probably don’t need anything else.
  • If your tree controls have strange background colors, try loading this MS Common Controls Update as wxWidgets does something that causes a bug in one of the older versions to manifest itself. Another way to get this update is to install Internet Explorer or MS Office apps, so if the system has those already then you probably don’t need to worry about this.
  • wxPython’s wx.glcanvas.GLCanvas class only provides the GL Context and a wx.Window to put it in, so if you want to use the wxGLCanvas you will also need the PyOpenGL Python extension modules as well.
  • Windows 95 users will probably also need the following items to update their systems:

Linux/Unix/Etc.

  • The first thing you’ll need are the glib and gtk+ libraries. Before you run off and download the sources check your system, you probably already have it. Most distributions of Linux come with it and you’ll start seeing it on many other systems too now that Sun and others have chosen GNOME as the desktop of choice. If you don’t have glib and gtk+ already, you can get the sources here. Build and install them following the directions included.

  • In order to use the wxGLCanvas you’ll need to have either OpenGL or the Mesa3D library on your system. wxPython’s wx.glcanvas.GLCanvas only provides the GL Context and a wx.Window to put it in, so you will also need the PyOpenGL Python extension modules as well, if you want to use OpenGL.

    If you are building wxPython yourself and don’t care to use OpenGL/Mesa then you can easily skip building it and can ignore this step. See the build instructions for details.

Mac OS X

  • wxPython needs a special Mac OS X-specific build of Python, called a Framework build, in order to work. Panther and Tiger include a Framework build of Python 2.3, or you can get a newer version of Python the Python Framework from the Python site.
  • Note to Fink users: Versions of Python installed by Fink or other unix-like package repositories cannot run wxPython (unless you install and run X11 and use a wxGTK version of wxPython...). You need to use Apple’s Framework builds, or a third-party Framework build to be able to have a native Aqua GUI.

OK, I’m interested. What do I do next?

You can download the Prebuild binary of wxPython which includes the source code for wxPython.

Prebuilt binaries are available for Microsoft Windows, Linux and Mac OS X.

Don’t forget to download the wxPython demo and the documentation!

Bleeding-edge source

If you are a very keen developer, you can access the SVN repository directly for this project in the wxWidgets SVN.

wxPython Documentation

The new wxPython API documentation is available in this page.