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

(yzsuai) #1

omitted (e.g., the File pull down menu and Quit button are gone). On the other hand,
you get all of the rest of PyEdit’s functionality, including cut and paste, search and
replace, grep to search external files, colors and fonts, undo and redo, and so on. Even
the Clone option works here to open a new edit window, albeit making a frame-based
menu without a Quit or File pull down, and which doesn’t test for changes on exit—
a usage mode that could be tightened up with a new PyEdit top-level component class
if desired.


For variety, if you pass a third command-line argument to PyView after the image
directory name, it uses it as an index into a list of PyEdit top-level mode classes. An
argument of 0 uses the main window mode, which places the note editor below the
image and a window menu at top (its Frame is packed into the window’s remaining
space, not the slide show frame); 1 pops up the note editor as a separate, independent
Toplevel window (disabled when notes are turned off); 2 and 3 run PyEdit as an em-
bedded component nested in the slide show frame, with Frame menus (2 includes all
menu options which may or may not be appropriate in this role, and 3 is the default
limited options mode).


Figure 11-15 captures option 0, PyEdit’s main window mode; there are really two in-
dependent frames on the window here—a slideshow on top and a text editor on bot-
tom. The disadvantage of this over nested component or pop-up window modes is that


Figure 11-14. PyView with notes


730 | Chapter 11: Complete GUI Programs

Free download pdf