Chapter 20. More GUIs

 

We made some simple GUIs back in chapter 6, when we used EasyGui to make some dialog boxes (or just “dialogs” for short). But GUIs need more than dialogs. In most modern programs, the whole program runs in a GUI. In this chapter, we’re going to look at making GUIs with PythonCard, which gives you more flexibility and control over how things look.

PythonCard is a module that helps you create GUIs. We’re first going to use it to make a version of our temperature-conversion program.

In the Good old Days

PythonCard was inspired by a much older piece of software called HyperCard. HyperCard was one of the first programs to make creating GUIs simple enough that everyday users could try it. HyperCard was software for the Apple Macintosh, which was one of the first home computers to use a GUI.

Working with PythonCard

Before using PythonCard, we have to make sure it is installed on your computer. If you installed Python using the book’s installer, PythonCard is already installed. If not, you’ll have to download and install it separately. You can get PythonCard from pythoncard.sourceforge.net. Make sure you get the correct version for your operating system and the version of Python you’re using (version 2.5, if you ran the installer).

In order for PythonCard to work, you’ll also need something called wxPython. Again, that’s installed with the book’s installer. If you need to download and install it separately, you can find it at www.wxpython.org.

Resource Editor

Components

Making our GUI do something

The return of event handlers

Moving the button

More useful GUIs

TempGUI

What’s on the menu?

What did you learn?

Test your knowledge

Try it out