window’s default appearance running in Windows 7, after opening PyEdit’s own source
code file.
The main part of this window is a Text widget object, and if you read Chapter 9’s
coverage of this widget, PyEdit text-editing operations will be familiar. It uses text
marks, tags, and indexes, and it implements cut-and-paste operations with the system
clipboard so that PyEdit can paste data to and from other applications, even after an
application of origin is closed. Both vertical and horizontal scroll bars are cross-linked
to the Text widget, to support movement through arbitrary files.
Menus and toolbars
If PyEdit’s menu and toolbars look familiar, they should—PyEdit builds the main win-
dow with minimal code and appropriate clipping and expansion policies by mixing in
the GuiMaker class we coded in the prior chapter (Example 10-3). The toolbar at the
bottom contains shortcut buttons for operations I tend to use most often; if my pref-
erences don’t match yours, simply change the toolbar list in the source code to show
the buttons you want (this is Python, after all).
As usual for tkinter menus, shortcut key combinations can be used to invoke menu
options quickly, too—press Alt plus all the underlined keys of entries along the path
to the desired action. Menus can also be torn off at their dashed line to provide quick
access to menu options in new top-level windows (handy for options without toolbar
buttons).
Figure 11-1. PyEdit main window, editing itself
676 | Chapter 11: Complete GUI Programs