Python
  Home arrow Python arrow Page 2 - The PyMailGUI Client
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PYTHON

The PyMailGUI Client
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2007-07-12


    Table of Contents:
  • The PyMailGUI Client
  • Source Code Modules
  • Why PyMailGUI?
  • Running PyMailGUI

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    The PyMailGUI Client - Source Code Modules
    ( Page 2 of 4 )

    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)
       Server sends and receives, parsing, construction
       (Chapter 14)

    Example 11-17: PP3E.Gui.Tools.threadtools.py
       Thread queue management for GUI callbacks
       (Chapter 11)

    Example 11-13: PP3E.Gui.Tools.windows.py
       Border configuration for top-level window (Chapter
       11)

    Example 12-4: PP3E.Gui.TextEditor.textEditor.py
      
    Text widget used in mail view windows, and in some 
       pop ups (Chapter 12)

    Some of these modules in turn use additional examples we coded earlier, but that are not imported by PyMailGUI itself ( textEditor , for instance, uses guimaker to 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
       Various pop-up windows, written for general use

    messagecache.py 
       A cache that keeps track of mail already loaded

    wraplines.py 
       A utility for wrapping long lines of messages

    mailconfig.py 
       User configuration parameters—server names, fonts,
       and so on (augmented here)

    Finally, the following are new modules coded in this chapter and are specific to the PyMailGUI program:

    SharedNames.py 
       Program-wide globals used by multiple files

    ViewWindows.py
       The implementation of View, Write, Reply, and 
       Forward message view windows

    ListWindows.py
       The implementation of mail-server and local-file 
       message list windows

    PyMailGuiHelp2.py
       User-oriented help text, opened by the main 
       window’s bar button

    PyMailGui2.py
       The main, top-level file of the program, run to launch
       the main window

    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:

    1. Python’s modules allowus to divide the system into files that have a cohesive purpose, with minimal coupling between them—code is easier to locate and understand if your modules have a logical, self-contained structure.
    2. Python’s OOP support allows us to factor code for reuse, and avoid redundancy—as you’ll see, code is customized, not repeated, and the classes we will code reflect the actual components of the GUI to make them easy to follow.

    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, the PyMailGuiHelp2.py module 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.



     
     
    >>> More Python Articles          >>> More By O'Reilly Media
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek