- Python’s POP and SMTP library modules are used to fetch, send, and delete mail
over sockets. - Python threads, if installed in your Python interpreter, are put to work to avoid
blocking during potentially overlapping, long-running mail operations.
We’re also going to reuse the PyEdit TextEditor object we wrote in Chapter 11 to view
and compose messages and to pop up raw text, attachments, and source; the mail
tools package’s tools we wrote in Chapter 13 to load, send, and delete mail with a
server; and the mailconfig module strategy introduced in Chapter 13 to support end-
user settings. PyMailGUI is largely an exercise in combining existing tools.
On the other hand, because this program is so long, we won’t exhaustively document
all of its code. Instead, we’ll begin with a quick look at how PyMailGUI has evolved,
and then move on to describing how it works today from an end user’s perspective—
a brief demo of its windows in action. After that, we’ll list the system’s new source code
modules without many additional comments, for further study.
Like most of the longer case studies in this book, this section assumes that you already
know enough Python to make sense of the code on your own. If you’ve been reading
this book linearly, you should also know enough about tkinter, threads, and mail in-
terfaces to understand the library tools applied here. If you get stuck, you may wish to
brush up on the presentation of these topics earlier in the book.
Major PyMailGUI Changes
Like the PyEdit text editor of Chapter 11, PyMailGUI serves as a good example of
software evolution in action. Because its revisions help document this system’s func-
tionality, and because this example is as much about software engineering as about
Python itself, let’s take a quick look at its recent changes.
New in Version 2.1 and 2.0 (Third Edition)
The 2.1 version of PyMailGUI presented in the third edition of the book in early 2006
is still largely present and current in this fourth edition in 2010. Version 2.1 added a
handful of enhancements to version 2.0, and version 2.0 was a complete rewrite of the
1.0 version of the second edition with a radically expanded feature set.
In fact, the second edition’s version 1.0 of this program written in early 2000 was only
some 685 total program lines long (515 lines for the GUI main script and 170 lines in
an email utilities module), not counting related examples reused, and just 60 lines in
its help text module. Version 1.0 was really something of a prototype (if not toy), written
mostly to serve as a short book example.
Although it did not yet support Internationalized mail content or other 3.0 extensions,
in the third edition, PyMailGUI 2.1 became a much more realistic and feature-rich
program that could be used for day-to-day email processing. It grew by nearly a factor
Major PyMailGUI Changes| 1011