[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

Multiple Windows and Status Messages


Finally, PyMailGUI is really meant to be a multiple-window interface—a detail that
most of the earlier screenshots haven’t really done justice to. For example, Fig-
ure 14-46 shows PyMailGUI with the main server list window, two save-file list win-
dows, two message view windows, and help. All these windows are nonmodal; that is,
they are all active and independent, and do not block other windows from being se-
lected, even though they are all running a single PyMailGUI process.


In general, you can have any number of mail view or compose windows up at once,
and cut and paste between them. This matters, because PyMailGUI must take care to
make sure that each window has a distinct text-editor object. If the text-editor object
were a global, or used globals internally, you’d likely see the same text in each window
(and the Send operations might wind up sending text from another window). To avoid
this, PyMailGUI creates and attaches a new TextEditor instance to each view and com-
pose window it creates, and associates the new editor with the Send button’s callback
handler to make sure we get the right text. This is just the usual OOP state retention,
but it acquires a tangible benefit here.


Though not GUI-related, PyMailGUI also prints a variety of status messages as it runs,
but you see them only if you launch the program from the system command-line console
window (e.g., a DOS box on Windows or an xterm on Linux) or by double-clicking on
its filename icon (its main script is a .py, not a .pyw). On Windows, you won’t see these


Figure 14-45. Alternative accounts and configurations


1060 | Chapter 14: The PyMailGUI Client

Free download pdf