This chapter is something of a self-study exercise. Because PyMailGUI is fairly large and mostly applies concepts we’ve already learned, we won’t go into much detail about its actual code. Instead, it is listed for you to read on your own. I encourage you to study the source and comments and to run this program on your own to get a feel for its operation. Also, be sure to refer back to the modules we introduced earlier in the book and are reusing here, to gain a full understanding of the system. For reference, here are the major examples that will see new action in this chapter: Example 14-21: PP3E.Internet.Email.mailtools (package) Example 11-17: PP3E.Gui.Tools.threadtools.py Example 11-13: PP3E.Gui.Tools.windows.py Example 12-4: PP3E.Gui.TextEditor.textEditor.py Some of these modules in turn use additional examples we coded earlier, but that are not imported by PyMailGUI itself (textEditor, for instance, usesguimakerto create its windows and toolbar). We’ll also be coding new modules here. The following new modules are intended to be useful in other programs: utilities.py messagecache.py wraplines.py mailconfig.py Finally, the following are new modules coded in this chapter and are specific to the PyMailGUI program: SharedNames.py ViewWindows.py ListWindows.py PyMailGuiHelp2.py PyMailGui2.py All told, PythonMailGUI comprises the nine new modules in the preceding two lists and is composed of some 2,200 lines of source code (including comments, whitespace, and 530 lines of help text). This doesn’t include the four other book examples in the previous list that are reused in PyMailGUI, which themselves constitute 1,600 additional lines.* This is the largest example we’ll see in this book, but you shouldn’t be deterred by its size. Because it uses modular and OOP techniques, the code is simpler than you may think:
For instance, the implementation of mail list windows is easy to read and change, because it has been factored into a common shared superclass, which is customized by subclasses for mail-server and save-file lists; since these are mostly just variations on a theme, most of the code appears in just one place. Similarly, the code that implements the message view window is a superclass shared by write, reply, and forward composition windows; subclasses simply tailor it for writing rather than viewing. Although we’ll deploy these techniques in the context of a mail processing program here, such techniques will apply to any nontrivial program you’ll write in Python. To help get you started, thePyMailGuiHelp2.pymodule listed last in this chapter includes a help text string that describes how this program is used, as well as its major features. Experimenting with the system, while referring to its code, is probably the best and quickest way to uncover its secrets.
blog comments powered by Disqus |
|
|
|
|
|
|
|