class BusyBoxWait(PopupWindow):
"""
pop up blocking wait message box: thread waits
main GUI event thread stays alive during wait
but GUI is inoperable during this wait state;
uses quit redef here because lower, not leftmost;
"""
def init(self, appname, message):
PopupWindow.init(self, appname, 'Busy')
self.protocol('WM_DELETE_WINDOW', lambda:0) # ignore deletes
label = Label(self, text=message + '...') # win.quit() to erase
label.config(height=10, width=40, cursor='watch') # busy cursor
label.pack()
self.makeModal()
self.message, self.label = message, label
def makeModal(self):
self.focus_set() # grab application
self.grab_set() # wait for threadexit
def changeText(self, newtext):
self.label.config(text=self.message + ': ' + newtext)
def quit(self):
self.destroy() # don't verify quit
class BusyBoxNowait(BusyBoxWait):
"""
pop up nonblocking wait window
call changeText to show progress, quit to close
"""
def makeModal(self):
pass
if name == 'main':
HelpPopup('spam', 'See figure 1...\n')
print(askPasswordWindow('spam', 'enter password'))
input('Enter to exit') # pause if clicked
wraplines: Line Split Tools
The module in Example 14-7 implements general tools for wrapping long lines, at either
a fixed column or the first delimiter at or before a fixed column. PyMailGUI uses this
file’s wrapText1 function for text in view, reply, and forward windows, but this code is
potentially useful in other programs. Run the file as a script to watch its self-test code
at work, and study its functions to see its text-processing logic.
Example 14-7. PP4E\Internet\Email\PyMailGui\wraplines.py
"""
###############################################################################
split lines on fixed columns or at delimiters before a column;
see also: related but different textwrap standard library module (2.3+);
4E caveat: this assumes str; supporting bytes might help avoid some decodes;
###############################################################################
"""
1100 | Chapter 14: The PyMailGUI Client