Python
  Home arrow Python arrow Page 2 - 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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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


    The PyMailGUI Module - SharedNames: Program-Wide Globals


    (Page 2 of 4 )

    The module in Example 15-2 implements a shared, system-wide namespace that collects resources used in most modules in the system, and defines global objects that span files. This allows other files to avoid redundantly repeating common imports, and encapsulates the locations of package imports; it is the only file that must be updated if paths change in the future. Using globals can make programs harder to understand in general (the source of some names is not as clear), but it is reasonable if all such names are collected in a single expected module such as this one (because there is only one place to search for unknown names).

    Example 15-2. PP3E\Internet\Email\PyMailGui\SharedNames.py

    ################################################################ # objects shared by all window classes and main file: program-wide globals ###############################################################

    # used in all window, icon titles
    appname = 'PyMailGUI 2.1'

    # used for list save, open, delete; also for sent messages file
    saveMailSeparator = 'PyMailGUI' + ('-'*60) + 'PyMailGUI\n'

    # currently viewed mail save files; also for sent-mail file
    openSaveFiles     = {}           # 1 window per file,{name:win}

    # standard library services
    import sys, os, email, webbrowser
    from Tkinter       import *
    from tkFileDialog  import SaveAs, Open, Directory
    from tkMessageBox  import showinfo, showerror, askyesno

    # reuse book examples
    from PP3E.Gui.Tools  import windows     # window border, exit protocols
    from PP3E.Gui.Tools  import threadtools # thread callback queue checker

    from PP3E.Internet.Email import mailtools # load,send,parse,build utilities
    from PP3E.Gui.TextEditor import textEditor # component and pop up
    # modules defined here
    import mailconfig # user params: servers, fonts, etc.
    import popuputil # help, busy, passwd pop-up windows
    import wraplines # wrap long message lines
    import messagecache # remember already loaded mail
    import PyMailGuiHelp # user documentation
      

    def printStack(exc_info):
        # debugging: show exception and stack traceback on stdout
       
    print exc_info[0]
       
    print exc_info[1]
       
    import traceback
       
    traceback.print_tb(exc_info[2], file=sys.stdout)

    # thread busy counters for threads run by this GUI
    # sendingBusy shared by all send windows, used by main window quit

    loadingHdrsBusy = threadtools.ThreadCounter()   # only 1
    deletingBusy    = threadtools.ThreadCounter()   # only 1
    loadingMsgsBusy = threadtools.ThreadCounter()   # poss many
    sendingBusy     = threadtools.ThreadCounter()   # poss many

    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

    - 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
    - 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...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT