Wpy, a Portable GUI Module for Python

Presented at the May 1995 Python Workshop by James C. Ahlstrom

Wpy is a Python module which provides a class library, a message system and other tools for writing portable graphical user interface (GUI) code. You import "wpy.py" into your Python program and use it to write GUI code which will run unchanged on Unix/X using Tk, or on Microsoft Windows 3.1 and NT. Python is ideally suited to GUI development since it is a fast object-oriented scripting language with advanced data types such as lists and dictionaries. Code written with wpy runs with native look and feel.

When running on Unix/X, wpy uses Tk to provide a high level interface to the X window system. The newest version of Tk (currently 4.0 beta 3) is required. Interface code to Tk is provided in the file "wpy_tk.py". When running on Microsoft Windows 95 or NT, the interface is provided by a C++ language module. The Windows version will also run on Windows 3.1 using a free "win32s" dynamic link library provided by Microsoft.

All the wpy source and binary versions are available from ftp.interet.com in /pub/python. This may be moved to www.python.org in the future. The software is free but carries no warranty. See the copyright notice. The software is currently (May 1995) somewhat preliminary, and is still under active development.

Design Goals

The best way to understand wpy is to look at the design goals which are as follows:

Wpy Design

Wpy has its own GUI class model. In view of the effort required to learn any GUI model, inventing a new model is not desirable. Instead, I attempted to identify a good popular class model which would be worthwhile to learn even apart from its use in wpy. In the end, the obvious choice was the Microsoft Foundation Class (MFC) model. Wpy follows MFC rather exactly in its classes and messages, but differs slightly in details such as method arguments. A knowledge of MFC makes writing in wpy easy and obvious, and even MFC documentation can be used for wpy. The reverse is also true, and wpy is a good way to learn MFC. The Python/wpy code looks more or less identical to the equivalent C++ version, but is faster and easier to write.

Wpy is being developed as a commercial quality language, but I believe that Python and wpy are also an excellent choice for a teaching language. The skills learned will translate directly to C++ without the risk of writing C and calling it C++.

MFC is a natural choice when running under Windows, and it is easy to see how a port would work. On Unix, the Tk interface is used. Tk is a command language interface to X widgets, and it is not a direct map to MFC or any other class library. Luckily Tk provides powerful commands which make it easy to implement high level features easily. In wpy, the Tk internals are hidden, and the GUI model is still MFC. Necessary support is provided in Python code which calls Tk commands through the tkinter module provided in standard Python.

Wpy Status

The feature set of wpy and the documentation will improve now that the design is complete. Currently (May 1995) only a few types of controls are implemented and even these could use more testing. Wpy only recently graduated from the "proof of concept" stage to the "in development" stage. So far, results are promising. I hope that wpy will be a useful addition to the already great Python language.

James C. Ahlstrom
May 30, 1995