Dialogs
PyEdit pops up a variety of modal and nonmodal dialogs, both standard and custom.
Figure 11-2 shows the custom and nonmodal change, font, and grep dialogs, along with
a standard dialog used to display file statistics (the final line count may vary, as I tend
to tweak code and comments right up until final draft).
Figure 11-2. PyEdit with colors, a font, and a few pop ups
The main window in Figure 11-2 has been given new foreground and background colors
(with the standard color selection dialog), and a new text font has been selected from
either the font dialog or a canned list in the script that users can change to suit their
preferences (this is Python, after all). Other toolbar and menu operations generally use
popped-up standard dialogs, with a few new twists. For instance, the standard file open
and save selection dialogs in PyEdit use object-based interfaces to remember the last
directory visited, so you don’t have to navigate there every time.
Running program code
One of the more unique features of PyEdit is that it can actually run Python program
code that you are editing. This isn’t as hard as it may sound either—because Python
provides built-ins for compiling and running code strings and for launching programs,
PyEdit simply has to make the right calls for this to work. For example, it’s easy to code
a simple-minded Python interpreter in Python, using code like the following (see file
PyEdit: A Text Editor Program/Object | 677