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

(yzsuai) #1

or displaying a simple one-button window that allows you to select directories to open
on demand, when no initial directory is given or present (see the code’s main logic).


PyPhoto also lets you open additional folders in new thumbnail windows, by pressing
the D key on your keyboard in either a thumbnail or an image window. Figure 11-8,
for instance, captures the pop-up window produced in Windows 7 to select a new image
folder, and Figure 11-9 shows the result when I select a directory copied from one of
my digital camera cards—this is a second PyPhoto thumbnail window on the display.
Figure 11-8 is also opened by the one-button window if no initial directory is available.


When a thumbnail is selected, the image is displayed in a canvas, in a new pop-up
window. If it’s too large for the display, you can scroll through its full size with the
window’s scroll bars. Figure 11-10 captures one image after its thumbnail is clicked,
and Figure 11-11 shows the Save As dialog issued when the S key is pressed in the image
window; be sure to type the desired filename extension (e.g., .jpg) in this Save As dialog,
because PIL uses it to know how to save the image to the file. In general, any number
of PyPhoto thumbnail and image windows can be open at once, and each image can
be saved independently.


Beyond the screenshots already shown, this system’s interaction is difficult to capture
in a static medium such as this book—you’re better off test-driving the program live.


Figure 11-7. PyPhoto main window, default directory


718 | Chapter 11: Complete GUI Programs

Free download pdf