may define their own version or configure this file on the module search path per their
needs.
PyEdit Changes in Version 2.1 (Fourth Edition)
Besides the updates described in the prior section, the following additional enhance-
ments were made for this current fourth edition of this book:
- PyEdit has been ported to run under Python 3.1, and its tkinter library.
- The nonmodal change and font dialogs were fixed to work better if multiple in-
stance windows are open: they now use per-dialog state. - A Quit request in main windows now verifies program exit if any other edit win-
dows in the process have changed content, instead of exiting silently. - There’s a new Grep menu option and dialog for searching external files; searches
are run in threads to avoid blocking the GUI and to allow multiple searches to
overlap in time and support Unicode text. - There was a minor fix for initial positioning when text is inserted initially into a
newly created editor, reflecting a change in underlying libraries. - The Run Code option for files now uses the base file name instead of the full di-
rectory path after a chdir to better support relative paths; allows for command-line
arguments to code run from files; and inherits a patch made in Chapter 5’s
launchmodes which converts / to \ in script paths. In addition, this option always
now runs an update between pop-up dialogs to ensure proper display. - Perhaps most prominently, PyEdit now processes files in such a way as to support
display and editing of text with arbitrary Unicode encodings, to the extent allowed
by the underlying Tk GUI library for Unicode strings. Specifically, Unicode is taken
into account when opening and saving files; when displaying text in the GUI; and
when searching files in directories.
The following sections provide additional implementation notes on these changes.
Modal dialog state fix
The change dialog in the prior version saved its entry widgets on the text editor object,
which meant that the most recent change dialog’s fields were used for every change
dialog open. This could even lead to program aborts for finds in an older change dialog
window if newer ones had been closed, since the closed window’s widgets had been
destroyed—an unanticipated usage mode, which has been present since at least the
second edition, and which I’d like to chalk up to operator error, but which was really
a lesson in state retention! The same phenomenon existed in the font dialog—its most
recently opened instance stole the show, though its brute force exception handler pre-
vented program aborts (it issued error pop ups instead). To fix, the change and font
684 | Chapter 11: Complete GUI Programs