Python
  Home arrow Python arrow Page 4 - 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 - Running PyMailGUI
    ( Page 4 of 4 )

    Of course, to script PyMailGUI on your own, you’ll need to be able to run it. PyMailGUI requires only a computer with some sort of Internet connectivity (a PC with a broadband or dial-up account will do) and an installed Python with the Tkinter extension enabled. The Windows port of Python has this capability, so Windows PC users should be able to run this program immediately by clicking its icon.

    Two notes on running the system: first, you’ll want to change the file mailconfig.py in the program’s source directory to reflect your account’s parameters, if you wish to send or receive mail from a live server; more on this as we interact with the system.

    Second, you can still experiment with the system without a live Internet connection—for a quick look at message view windows, use the main window’s Open buttons to open saved-mail files stored in the program’s SavedMail directory. In fact, the PyDemos launcher script at the top of the book’s examples directory forces PyMailGUI to open saved-mail files by passing filenames on the command line.

    Presentation Strategy

    PyMailGUI is easily the largest program in this book, but it doesn’t introduce many library interfaces that we haven’t already seen in this book. For instance:

    1. The PyMailGUI interface is built with Python’s Tkinter, using the familiar list-boxes, buttons, and text widgets we met earlier.
    2. Python’s email package is applied to pull-out headers, text, and attachments of messages, and to compose the same.
    3. Python’s POP and SMTP library modules are used to fetch, send, and delete mail over sockets.
    4. Python threads, if installed in your Python interpreter, are put to work to avoid blocking during potentially overlapping, long-running mail operations.

    We’re also going to reuse the TextEditor object we wrote in Chapter 12 to view and compose messages, the mailtools package’s tools we wrote in Chapter 14 to load and delete mail from the server, and the mailconfig module strategy introduced in Chapter 14 to support end-user settings. PyMailGUI is largely an exercise in combining existing tools.

    On the other hand, because this program is so long, we won’t exhaustively document all of its code. Instead, we’ll begin by describing how PyMailGUI works from an end user’s perspective—a brief demo of its windows in action. After that, we’ll list the system’s new source code modules without many additional comments, for further study.

    Like most of the longer case studies in this book, this section assumes that you already know enough Python to make sense of the code on your own. If you’ve been reading this book linearly, you should also know enough about Tkinter, threads, and mail interfaces to understand the library tools applied here. If you get stuck, you may wish to brush up on the presentation of these topics earlier in the book.

    New in This Edition

    The 2.1 version of PyMailGUI presented in this third edition of the book is a complete rewrite of the 1.0 version of the prior edition. The main script in the second edition’s version was only some 500 lines long, and was really something of a toy or prototype, written mostly to serve as a book example. In this edition, PyMailGUI is a much more realistic and full-featured program that can be used for day-to-day email processing. It has grown to 2,200 source lines (3,800 including related modules that are reused). Among its new weapons are these:

    1. MIME multipart mails with attachments may be both viewed and composed.
    2. Mail transfers are no longer blocking, and may overlap in time.
    3. Mail may be saved and processed offline from a local file.
    4. Message parts may now be opened automatically within the GUI.
    5. Multiple messages may be selected for processing in list windows.
    6. Initial downloads fetch mail headers only; full mails are fetched on request.
    7. View window headers and list window columns are configurable.
    8. Deletions are performed immediately, not delayed until program exit.
    9. Most server transfers report their progress in the GUI.
    10. Long lines are intelligently wrapped in viewed and quoted text.
    11. Fonts and colors in list and view windows may be configured by the user.
    12. Authenticating SMTP mail-send servers that require login are supported.
    13. Sent messages are saved in a local file, which may be opened in the GUI.
    14. View windows intelligently pick a main text part to be displayed.
    15. Already fetched mail headers and full mails are cached for speed.
    16. Date strings and addresses in composed mails are formatted properly.
    17. View windows now have quick-access buttons for attachments/parts (2.1).
    18. Inbox out-of-sync errors are detected on deletes, and on index and mail loads (2.1).
    19. Save-mail file loads and deletes are threaded, to avoid pauses for large files (2.1).

    The last three items on this list were added in version 2.1; the rest were part of the 2.0 rewrite. Some of these changes were made simple by growth in standard library tools (e.g., support for attachments is straightforward with the new email package), but most represent changes in PyMailGUI itself. There have also been a few genuine fixes: addresses are parsed more accurately, and date and time formats in sent mails are now standards conforming, because these tasks use new tools in the email package.

    Although there is still room for improvement (see the list at the end of this chapter), the program provides a full-featured interface, represents the most substantial example in this book, and serves to demonstrate a realistic application of the Python language. As its users often attest, Python may be fun to work with, but it’s also useful for writing practical and nontrivial software.

    Please check back next week for the continuation of this article.



     
     
    >>> 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 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek