Wrapping Up Top-Level Window Interfaces

Top-level window interfaces were introduced in Chapter 9. This section picks up where that introduction left off and wraps up those interfaces in classes that automate some of the work of building top-level windows—setting titles, finding and displaying window icons, issuing proper close actions based on a window’s role, intercepting window manager close button clicks, and so on.

Example 11-13 provides wrapper classes for the most common window types—a main application window, a transient pop-up window, and an embedded GUI component window. These window types vary slightly in terms of their close operations, but most inherit common functionality related to window borders: icons, titles, and close buttons. By creating, mixing in, or subclassing the class for the type of window you wish to make, you’ll get all the setup logic for free.

Example 11-13. PP3E\Gui\Tools\windows.py

############################################################################### # classes that encapsulate top-level interfaces; # allows same GUI to be main, pop-up, or attached; content classes may inherit # from these directly, or be mixed together with them per usage mode; may also # be called directly without a subclass; designed to be mixed in after (further # to the right than) app-specific classes: else, subclass gets methods here # (destroy, okayToQuit), instead of from app-specific classes--can't redefine. ############################################################################### ...

Get Programming Python, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.