entire PyMailGUI session to decode fetched message bytes to the required str text prior
to parsing, and to save and load full message text to save files. Users may set this variable
to a Unicode encoding name string which works for their mails’ encodings; “latin-1”,
“utf-8”, and “ascii” are reasonable guesses for most emails, as email standards originally
called for ASCII (though “latin-1” was required to decode some old mail save files
generated by the prior version). If decoding with this encoding name fails, other com-
mon encodings are attempted, and as a last resort the message is still displayed if its
headers can be decoded, but its body is changed to an error message; to view such
unlikely mails, try running PyMailGUI again with a different encoding.
In the negatives column, nothing is done about the Unicode format for the full text of
sent mails, apart from that inherited from Python’s libraries (as we learned in Chap-
ter 13, smtplib attempts to encode per ASCII when messages are sent, which is one
reason that header encoding is required). And while mail content character sets are
fully supported, the GUI itself still uses English for its labels and buttons.
As explained in Chapter 13, this program’s Unicode polices are a broad but partial
solution, because the email package in Python 3.1, upon which PyMailGUI utterly relies
for correct operation, is in a state of flux for some use cases. An updated version which
handles the Python 3.X str/bytes distinctions more accurately and completely is likely
to appear in the future; watch this book’s updates page (see the Preface) for future
changes and improvements to this program’s Unicode policies. Hopefully, the current
email package underlying PyMailGUI 3.0 will be available for some time to come.
Although there is still room for improvement (see the list at the end of this chapter),
the PyMailGUI program is able to provide a full-featured email interface, represents
the most substantial example in this book, and serves to demonstrate a realistic appli-
cation of the Python language and software engineering at large. As its users often attest,
Python may be fun to work with, but it’s also useful for writing practical and nontrivial
software. This example, more than any other in this book, testifies the same. The next
section shows how.
A PyMailGUI Demo
PyMailGUI is a multiwindow interface. It consists of the following:
- A main mail-server list window opened initially, for online mail processing
- One or more mail save-file list windows for offline mail processing
- One or more mail-view windows for viewing and editing messages
- PyEdit windows for displaying raw mail text, extracted text parts, and the system’s
source code - Nonblocking busy state pop-up dialogs
- Assorted pop-up dialogs for opened message parts, help, and more
A PyMailGUI Demo| 1019