Creating a managed layout
Though the wxPython Sizer
API provides a relatively convenient way to handle programmatically laying out controls, you may find yourself repeating common layout patterns in your application. If your application has some common layout patterns that can be reused in many places, it can be convenient to encapsulate and hide some of the layout in some reusable Panel
classes that manage specific ways of presenting the controls. In this recipe, we will create a managed layout panel that supports displaying a main content pane as well as a specialized function panel, which can be used to create and display application-defined buttons.
How to do it…
Perform the following steps:
First, we will define a class to be used as the layout manager and container for the function bar, as follows:
class FunctionPanel(wx.Panel): def __init__(self, parent): super(FunctionPanel, self).__init__(parent) self._pane = None self._bar = FunctionBar(self) self...