wx Basics¶
Concept¶
wxPython is a Wrapper around the wxWidgets GUI library, which is written in C++.
See here for an overview, including Hello World application example: https://wxpython.org/pages/overview/
Here you can find a more comprehensive Getting Started guide: https://wiki.wxpython.org/Getting%20Started
Sizers (Layout Managers)¶
- With wxWidgets/wxPython and similar toolkits, usually controls are not placed at pixel positions on their windows, but the layout of a window is managed by sizers.
- There are horizontal box sizers, vertical box sizers and grid sizers.
- The box sizers may have a label and a box around them. In this case they’re called static box sizers.
- Each sizer and contained sizer items can be fixed size or grow to fill the available space, e.g. when the window is resized.
Examples¶
Example application: Calculator window¶
![]() |
This window is managed by one vertical box sizer with six slots for the five rows plus a horizontal line and five horizontal box sizers for e.g. one label and one button:
Later we’ll have a look at alternative structures which allow better alignment of the fields.
wxGlade Requirements / Restrictions¶
The user interface and internal data structures of wxGlade impose some restrictions on the structure of a window. A frame or panel can’t have a widget as direct child; they always need a toplevel sizer first. So don’t be surprised to see constructions like:
- frame -> sizer with single slot -> panel -> sizer ….
- frame -> sizer with single slot -> notebook -> …
On the other hand, a notebook or a splitter can have widgets as direct children.