else:
Button(tools, text=title, command=callback).pack(side=LEFT)
add multiselect listbox with scrollbars
listwide = mailconfig.listWidth or 74 # 3.0: config start size
listhigh = mailconfig.listHeight or 15 # wide=chars, high=lines
mails = Frame(self)
vscroll = Scrollbar(mails)
hscroll = Scrollbar(mails, orient='horizontal')
fontsz = (sys.platform[:3] == 'win' and 8) or 10 # defaults
listbg = mailconfig.listbg or 'white'
listfg = mailconfig.listfg or 'black'
listfont = mailconfig.listfont or ('courier', fontsz, 'normal')
listbox = Listbox(mails, bg=listbg, fg=listfg, font=listfont)
listbox.config(selectmode=EXTENDED)
listbox.config(width=listwide, height=listhigh) # 3.0: init wider
listbox.bind('
crosslink listbox and scrollbars
vscroll.config(command=listbox.yview, relief=SUNKEN)
hscroll.config(command=listbox.xview, relief=SUNKEN)
listbox.config(yscrollcommand=vscroll.set, relief=SUNKEN)
listbox.config(xscrollcommand=hscroll.set)
pack last = clip first
mails.pack(side=TOP, expand=YES, fill=BOTH)
vscroll.pack(side=RIGHT, fill=BOTH)
hscroll.pack(side=BOTTOM, fill=BOTH)
listbox.pack(side=LEFT, expand=YES, fill=BOTH)
self.listBox = listbox
#################
event handlers
#################
def onCheckAll(self):
all or none click
if self.allModeVar.get():
self.listBox.select_set(0, END)
else:
self.listBox.select_clear(0, END)
def onViewRawMail(self):
possibly threaded: view selected messages - raw text headers, body
msgnums = self.verifySelectedMsgs()
if msgnums:
self.getMessages(msgnums, after=lambda: self.contViewRaw(msgnums))
def contViewRaw(self, msgnums, pyedit=True): # do we need full TextEditor?
for msgnum in msgnums: # could be a nested def
fulltext = self.getMessage(msgnum) # fulltext is Unicode decoded
if not pyedit:
display in a scrolledtext
from tkinter.scrolledtext import ScrolledText
window = windows.QuietPopupWindow(appname, 'raw message viewer')
1070 | Chapter 14: The PyMailGUI Client