Operationally, PyMailGUI runs as a set of parallel threads, which may overlap in time:
one for each active server transfer, and one for each active offline save file load or
deletion. PyMailGUI supports mail save files, automatic saves of sent messages, con-
figurable fonts and colors, viewing and adding attachments, main message text extrac-
tion, plain text conversion for HTML, and much more.
To make this case study easier to understand, let’s begin by seeing what PyMailGUI
actually does—its user interaction and email processing functionality—before jumping
into the Python code that implements that behavior. As you read this part, feel free to
jump ahead to the code listings that appear after the screenshots, but be sure to read
this section, too; this, along with the prior discussion of version changes, is where some
subtleties of PyMailGUI’s design are explained. After this section, you are invited to
study the system’s Python source code listings on your own for a better and more
complete explanation than can be crafted in English.
Getting Started
OK, it’s time to take the system out for a test drive. I’m going to run the following demo
on my Windows 7 laptop. It may look slightly different on different platforms (includ-
ing other versions of Windows) thanks to the GUI toolkit’s native-look-and-feel sup-
port, but the basic functionality will be similar.
PyMailGUI is a Python/tkinter program, run by executing its top-level script file,
PyMailGui.py. Like other Python programs, PyMailGUI can be started from the system
command line, by clicking on its filename icon in a file explorer interface, or by pressing
its button in the PyDemos or PyGadgets launcher bar. However it is started, the first
window PyMailGUI presents is captured in Figure 14-1, shown after running a Load
to fetch mail headers from my ISP’s email server. Notice the “PY” window icon: this is
the handiwork of window protocol tools we wrote earlier in this book. Also notice the
non-ASCII subject lines here; I’ll talk about Internationalization features later.
This is the PyMailGUI main window—every operation starts here. It consists of:
- A help button (the bar at the top)
- A clickable email list area for fetched emails (the middle section)
- A button bar at the bottom for processing messages selected in the list area
In normal operation, users load their email, select an email from the list area by clicking
on it, and press a button at the bottom to process it. No mail messages are shown
initially; we need to first load them with the Load button—a simple password input
dialog is displayed, a busy dialog appears that counts down message headers being
downloaded to give a status indication, and the index is filled with messages ready to
be selected.
1020 | Chapter 14: The PyMailGUI Client