from ViewWindows import ViewWindow, WriteWindow, ReplyWindow, ForwardWindow
###############################################################################
main frame - general structure for both file and server message lists
###############################################################################
class PyMailCommon(mailtools.MailParser):
"""
an abstract widget package, with main mail listbox;
mixed in with a Tk, Toplevel, or Frame by top-level window classes;
must be customized in mode-specific subclass with actions() and other;
creates view and write windows on demand: they serve as MailSenders;
"""
class attrs shared by all list windows
threadLoopStarted = False # started by first window
queueChecksPerSecond = 20 # tweak if CPU use too high
queueDelay = 1000 // queueChecksPerSecond # min msecs between timer events
queueBatch = 5 # max callbacks per timer event
all windows use same dialogs: remember last dirs
openDialog = Open(title=appname + ': Open Mail File')
saveDialog = SaveAs(title=appname + ': Append Mail File')
3.0: avoid downloading (fetching) same message in parallel
beingFetched = set()
def init(self):
self.makeWidgets() # draw my contents: list,tools
if not PyMailCommon.threadLoopStarted:
start thread exit check loop
a timer event loop that dispatches queued GUI callbacks;
just one loop for all windows: server,file,views can all thread;
self is a Tk, Toplevel,or Frame: any widget type will suffice;
3.0/4E: added queue delay/batch for progress speedup: ~100x/sec;
PyMailCommon.threadLoopStarted = True
threadtools.threadChecker(self, self.queueDelay, self.queueBatch)
def makeWidgets(self):
add all/none checkbtn at bottom
tools = Frame(self, relief=SUNKEN, bd=2, cursor='hand2') # 3.0: configs
tools.pack(side=BOTTOM, fill=X)
self.allModeVar = IntVar()
chk = Checkbutton(tools, text="All")
chk.config(variable=self.allModeVar, command=self.onCheckAll)
chk.pack(side=RIGHT)
add main buttons at bottom toolbar
for (title, callback) in self.actions():
if not callback:
sep = Label(tools, text=title) # 3.0: separator
sep.pack(side=LEFT, expand=YES, fill=BOTH) # expands with window
PyMailGUI Implementation| 1069