Home

  Window Layout

wxPython offers various flavours of window layout. The two main systems are Constraints and Sizers.

Constraints allow layout relationships to be setup between controls and edges.
A constraint must define 4 valid individual layout constraints or chaos will ensue.
Boa offers support but not complete integration of constraints currently. They can be set up in the Collection Editor accessible from the Constraints property of controls.
One problem is currently is that the relative offsets (margin and value) are not kept in sync when controls are moved and sized.

There are two more modules to help with this somewhat tedious to setup, but powerful layout mechanism.
They can be found in wxPython.lib as layoutf and anchors.
With layoutf constraints can be specified in concise printf like format. There is no built-in support for layoutf in Boa but they can be added by hand. See the layoutf's source for documentation
The LayoutAnchors class in anchors derives from wxLayoutConstraint and can be used in it's place. They offer a simple subset of normal constraints where the sides of a control may be 'anchored' on it's parent. Anchors are completely integrated into the Designer and available by right clicking on a selection tag in the Designer or from the Anchors property of controls.
See LayoutAnchors for detailed info.

Sizers allow controls and other sizers to be packed horizontally and vertically in window. They can grow, align to sides, proportionally resize or be centered.
Boa has no built-in support for sizers currently. I have trouble integrating them into Boa's current design time framework. They also need special visual support in the Designer , and the 'packing' of controls goes against the current placing and sizing methodology. Support is planned at a later stage.
Remember that you can always add Sizers by hand (to __init__) if you really need them.

Please note that a window's AutoLayout property should be set to true for the window to automatically apply layout for sizers and constraints. If this is not set you'll have to call Layout() yourself in the OnSize event of the window, but constraints will not be applied for that window at design-time.

See examples under Examples/layout


Boa Constructor - Application Help - Window Layout