entered encoding name to display properly in PyEdit (and won’t display correctly at all
in Notepad).
After I enter the encoding name for the selected file (“koi8-r” for the file selected to
open) in the input dialog of Figure 11-5, PyEdit decodes and pops up the text in its
display. Figure 11-6 show the scene after this file has been opened and I’ve selected the
Save As option in this window—immediately after a file selection dialog is dismissed,
another encoding input dialog is presented for the new file, prefilled with the known
encoding from the last Open or Save. As configured, Save reuses the known encoding
automatically to write to the file again, but SaveAs always asks to allow for a new one,
before trying defaults. Again, I’ll say more on the Unicode/Internationalization policies
of PyEdit in the next section, when we discuss version 2.1 changes; in short, because
user preferences can’t be predicted, a variety of policies may be selected by
configuration.
Finally, when it’s time to shut down for the day, PyEdit does what it can to avoid losing
changes not saved. When a Quit is requested for any edit window, PyEdit checks for
changes and verifies the operation in a dialog if the window’s text has been modified
and not saved. Because there may be multiple edit windows in the same process, when
a Quit is requested in a main window, PyEdit also checks for changes in all other win-
dows still open, and verifies exit if any have been altered—otherwise the Quit would
close every window silently. Quits in pop-up edit windows destroy that window only,
so no cross-process check is made. If no changes have been made, Quit requests in the
GUI close windows and programs silently. Other operations verify changes in similar
ways.
Figure 11-5. PyEdit displaying Chinese text and prompting for encoding on Open
PyEdit: A Text Editor Program/Object | 681