Share

Box layout

There are two box layouts: VBoxLayout (vertical) and HBoxLayout (horizontal). When you add a control (or even another layout) to these layouts, the controls are aligned either vertically or horizontally.

To add the controls, do one of the following:

  • Specify a fixed size with BoxLayout::Add: width for horizontal layout, and height for vertical layout. When you resize a layout, the fixed-size controls stay the same.
  • Specify a ratio with BoxLayout::AddRelative. With ratio, once all controls are in the layout, space is allocated to all controls having a fixed size. Then the remaining space is shared with all other controls according to their ratio. When you resize a layout, the size of the ratio controls is updated.

The sample TutorialBox.py shows how to create a vertical layout containing: a label, a container occupying two thirds of the space, and a memo (text control) occupying the remaining space. See the BoxLayout.py sample for more examples.

Was this information helpful?