[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

###############################################################################


main window - when viewing messages on the mail server


###############################################################################


class PyMailServer(PyMailCommon):
"""
customize PyMailCommon for viewing mail still on server;
mixed with a Tk, Toplevel, or Frame, adds main mail listbox;
maps load, fetch, delete actions to email server inbox;
embeds a MessageCache, which is a mailtools MailFetcher;
"""
def actions(self):
return [ ('Load', self.onLoadServer),
('Open', self.onOpenMailFile),
('Write', self.onWriteMail),
(' ', None), # 3.0: separators
('View', self.onViewFormatMail),
('Reply', self.onReplyMail),
('Fwd', self.onFwdMail),
('Save', self.onSaveMailFile),
('Delete', self.onDeleteMail),
(' ', None),
('Quit', self.quit) ]


def init(self):
PyMailCommon.init(self)
self.cache = messagecache.GuiMessageCache() # embedded, not inherited
#self.listBox.insert(END, 'Press Load to fetch mail')


def makeWidgets(self): # help bar: main win only
self.addHelpBar()
PyMailCommon.makeWidgets(self)


def addHelpBar(self):
msg = 'PyMailGUI - a Python/tkinter email client (help)'
title = Button(self, text=msg)
title.config(bg='steelblue', fg='white', relief=RIDGE)
title.config(command=self.onShowHelp)
title.pack(fill=X)


def onShowHelp(self):
"""
load,show text block string
3.0: now uses HTML and webbrowser module here too
user setting in mailconfig selects text, HTML, or both
always displays one or the other: html if both false
"""
if mailconfig.showHelpAsText:
from PyMailGuiHelp import helptext
popuputil.HelpPopup(appname, helptext, showsource=self.onShowMySource)


if mailconfig.showHelpAsHTML or (not mailconfig.showHelpAsText):


PyMailGUI Implementation| 1081
Free download pdf