Python
  Home arrow Python arrow The PyMailGUI Module
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
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? 
PYTHON

The PyMailGUI Module
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2007-08-08

    Table of Contents:
  • The PyMailGUI Module
  • SharedNames: Program-Wide Globals
  • ListWindows: Message List Windows
  • ViewWindows: Message View Windows

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    The PyMailGUI Module


    (Page 1 of 4 )

    In the fifth part of a six-part series, we take a look at the main module for PyMailGUI. This article is excerpted from chapter 15 of the book Programming Python, Third Edition, written by Mark Lutz (O'Reilly, 2006; ISBN: 0596009259) Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    PyMailGui2: The Main Module

    Example 15-1 defines the file run to start PyMailGUI. It implements top-level list windows in the system—combinations of PyMailGUI’s application logic and the window protocol superclasses we wrote earlier in the text. The latter of these define window titles, icons, and close behavior.

    The main documentation is also in this module, as well as command-line logic—the program accepts the names of one or more save-mail files on the command line, and automatically opens them when the GUI starts up. This is used by the PyDemos launcher, for example.

    Example 15-1. PP3E\Internet\Email\PyMailGui\PyMailGui2.py

    ##############################################################
    # PyMailGui 2.1 - A Python/Tkinter email client.
    # A client-side Tkinter-based GUI interface for sending and receiving email.
    #
    # See the help string in PyMailGuiHelp2.py for usage details, and a list of
    # enhancements in this version. Version 2.0 is a major rewrite. The changes
    # from 2.0 (July '05) to 2.1 (Jan '06) were quick-access part buttons on View
    # windows, threaded loads and deletes of local save-mail files, and checks for
    # and recovery from message numbers out-of-synch with mail server inbox on
    # deletes, index loads, and message loads.
    #
    # This file implements the top-level windows and interface. PyMailGui uses
    # a number of modules that know nothing about this GUI, but perform related
    # tasks, some of which are developed in other sections of the book. The
    # mailconfig module is expanded for this program.
    #
    # Modules defined elsewhere and reused here:
    #
    # mailtools (package):
    #    server sends and receives, parsing, construction (client-side chapter)
    # threadtools.py
    #    thread queue manangement for GUI callbacks (GUI tools chapter)
    # windows.py
    #    border configuration for top-level windows (GUI tools chapter)
    # textEditor.py
    #    text widget used in mail view windows, some pop ups           (GUI programs chapter)
    #
    # Generally useful modules defined here:
    #
    # popuputil.py
    #    help and busy windows, for general use
    # messagecache.py
    #    a cache that keeps track of mail already loaded
    # wraplines.py
    #    utility for wrapping long lines of messages
    # mailconfig.py
    #    user configuration parameters: server names, fonts, etc.
    #
    # Program-specific modules defined here:
    #
    # SharedNames.py
    #    objects shared between window classes and main file
    # ViewWindows.py
    #    implementation of view, write, reply, forward windows
    # ListWindows.py
    #    implementation of mail-server and local-file list windows
    # PyMailGuiHelp.py
    #    user-visible help text, opened by main window bar
    # PyMailGui2.py
    #    main, top-level file (run this), with main window types
    #############################################################

    import mailconfig, sys
    from SharedNames import appname, windows
    from ListWindows import PyMailServer, PyMailFile

     

    #############################################################
    # Top-level window classes
    # View, Write, Reply, Forward, Help, BusyBox all inherit from PopupWindow
    # directly: only usage; askpassword calls PopupWindow and attaches; order
    # matters here!--PyMail classes redef some method defaults in the Window
    # classes, like destroy and okayToExit: must be leftmost; to use
    # PyMailFileWindow standalone, imitate logic in PyMailCommon.onOpenMailFile;
    ###############################################################

    # uses icon file in cwd or default in tools dir
    srvrname = mailconfig.popservername or 'Server'

    class PyMailServerWindow(PyMailServer, windows.MainWindow):
       def _ _init_ _(self):
           windows.MainWindow._ _init_ _(self, appname, srvrname)
           PyMailServer._ _init_ _(self)

    class PyMailServerPopup(PyMailServer, windows.PopupWindow):
       def _ _init_ _(self):
           windows.PopupWindow._ _init_ _(self, appname, srvrnane)
           PyMailServer._ _init_ _(self)

    class PyMailServerComponent(PyMailServer, windows.ComponentWindow):
       def _ _init_ _(self):
           windows.ComponentWindow._ _init_ _(self)
           PyMailServer._ _init_ _(self)

    class PyMailFileWindow(PyMailFile, windows.PopupWindow):
       def _ _init_ _(self, filename):
      
    windows.PopupWindow.__init__(self, appname, filename)
       PyMailFile.__init__(self, filename)

    ############################################################### # when run as a top-level program: create main mail-server list window ###############################################################

    if __name_ _ == '__main__':

    rootwin = PyMailServerWindow() # open server window
    if sys.argv > 1: 
    for savename in sys.argv[1:]: 
    rootwin.onOpenMailFile(savename) # open save file windows (demo)
    rootwin.lift() # save files loaded in threads
    rootwin.mainloop()  

    More Python Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Python, Third Edition,"...
     

    Buy this book now. This article is excerpted from chapter 15 of the book Programming Python, Third Edition, written by Mark Lutz (O'Reilly, 2006; ISBN: 0596009259). Check it out today at your favorite bookstore. Buy this book now.

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway