O'Reilly logo

Programming Python, 3rd Edition by Mark Lutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ############################################################################### ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required