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  
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? 
PYTHON

The PyMailGUI Module
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      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 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
     

       

    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 1 Hosted by Hostway
    Stay green...Green IT