Since the current version inherits all the enhancements of the one preceding it, let’s
begin with the previous version’s additions. In the third edition, PyEdit was enhanced
with:
- A simple font specification dialog
- Unlimited undo and redo of editing operations
- File modified tests whenever content might be erased or changed
- A user configurations module
Here are some quick notes about these extensions.
Font dialog
For the third edition of the book, PyEdit grew a font input dialog—a simple, three-entry,
nonmodal dialog where you can type the font family, size, and style, instead of picking
them from a list of preset options. Though functional, you can find more sophisticated
tkinter font selection dialogs in both the public domain and within the implementation
of Python’s standard IDLE development GUI (as mentioned earlier, it is itself a Python/
tkinter program).
Undo, redo, and modified tests
Also new in the third edition, PyEdit supports unlimited edit undo and redo, as well as
an accurate modified check before quit, open, run, and new actions to prompt for saves.
It now verifies exits or overwrites only if text has been changed, instead of always asking
naïvely. The underlying Tk 8.4 (or later) library provides an API, which makes both
these enhancements simple—Tk keeps undo and redo stacks automatically. They are
enabled with the Text widget’s undo configuration option and are accessed with the
widget methods edit_undo and edit_redo. Similarly, edit_reset clears the stacks (e.g.,
after a new file open), and edit_modified checks or sets the automatic text modified flag.
It’s also possible to undo cuts and pastes right after you’ve done them (simply paste
back from the clipboard or cut the pasted and selected text), but the new undo/redo
operations are more complete and simpler to use. Undo was a suggested exercise in the
second edition of this book, but it has been made almost trivial by the new Tk API.
Configuration module
For usability, the third edition’s version of PyEdit also allows users to set startup con-
figuration options by assigning variables in a module, textConfig.py. If present on the
module search path when PyEdit is imported or run, these assignments give initial
values for font, colors, text window size, and search case sensitivity. Fonts and colors
can be changed interactively in the menus and windows can be freely resized, so this
is largely just a convenience. Also note that this module’s settings will be inherited by
all instances of PyEdit if it is importable in the client program—even when it is a pop-
up window or an embedded component of another application. Client applications
PyEdit: A Text Editor Program/Object | 683