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

(yzsuai) #1

For example, View opens the selected message in a normal mail view window identical
to that in Figure 14-5, but the mail originates from the local file. Similarly, Delete re-
moves the message from the save file, instead of from the server’s inbox. Deletions from
save-mail files are also run in a thread, to avoid blocking the rest of the GUI—the
window title changes to “Deleting...” during the delete as a status indicator. Status
indicators for loads and deletions in the server inbox window use pop ups instead,
because the wait is longer and there is progress to display (see Figure 14-8).


Technically, saves always append raw message text to the chosen file; the file is opened
in 'a' mode to append text, which creates the file if it’s new and writes at its end. The
Save and Open operations are also smart enough to remember the last directory you
selected; their file dialogs begin navigation there the next time you press Save or Open.


You can also save mails from a saved file’s window—use Save and Delete to move mails
from file to file. In addition, saving to a file whose window is open for viewing auto-
matically updates that file’s list window in the GUI. This is also true for the automat-
ically written sent-mail save file, described in the next section.


Sending Email and Attachments


Once we’ve loaded email from the server or opened a local save file, we can process
our messages with the action buttons at the bottom of list windows. We can also send
new emails at any time, even before a load or open. Pressing the Write button in any
list window (server or file) generates a mail composition window; one has been cap-
tured in Figure 14-14.


Figure 14-13. List window for mail save file, multiple selections


A PyMailGUI Demo| 1033
Free download pdf