Size
Width and Height
The size of a widget is determined by its width
and height
properties, which both have the type of Units
enum, which has four variants:
- Auto:
- If the layout type is a column, then auto width will be the maximm child width and auto height will be the sum of the heights of its children.
- If the layout type is a row, then auto width will be the sum of the widths of its children and auto height will be the maximum child height.
- Stretch:
- The width/height will stretch to fill some proportion of the remaining available space. The remaining available space is the space left after subtracting the width/height of non-stretch children.
- Percentage:
- The width/height is a specified proportion of the parent width/height, unless overriden by min_/max_ width/height.
- Pixels:
- The width/height is a specified number of pixels, unless overriden by min_/max_ width/height.
Size Constraints
The width and height of a widget can be constrained by speifying a minimum and maxium using min_width
, max_width
, min_height
, and max_height
. These properties override the width and height properties and can be specified in Units
:
-
Auto:
- If the layout type is a column then the min_width
-
Stretch:
-
Percentage:
-
Pixels:
Position
Child widgets added to a parent are arranged into either a vertical column, a horizontal row, or a grid and is determined by he layout_type
property:
- Col:
- Child widgets are arranged into a verical column.
- Row:
- Child widgets are arranged into a horizontal row.
- Grid:
- Child widgets are positioned by a row and column indices and their size is determined by row and column spans.
Position Type
The position_type
property specifies whether a widget should be affected by the position of the other child widgets.
- Parent-directed:
- The widget is positioned by the parent relative to its usual position within a column, row, or grid.
- Self-directed:
- The widget is positioned relative to the top-left corner of the parent and is not affected by sibling widgets.
Space
The position of a widget can be modified by adding space to the left
, right
, top
, and bottom
, and is also specified in Units
. All four properties can be set simultaneously with the space
property.
- Auto:
- The space is determined by the parents
child_space
properties. For example, an autoleft
is overriden by the parentschild_left
property.
- The space is determined by the parents
- Stretch:
- The space is a specified proportion of the available remaining space.
- Percentage:
- The space is a specified proportion of the parent width/height, unless overridden by min/max constraints.
- Pixels:
- The space is a specified number of pixels, unless overridden by min/max constraints.
Space Constraints
The space properties can also be constrained with minimums and maximums, also using Units
:
- Auto:
- Stretch:
- Percentage:
- Pixels:
Child Space
While space
is used to set the spacing of individual widgets, child_space
is used to set the spacing of all child widgets in one go, as long that the child space properties are set to auto. Child space can be considered similar to padding and is also specified in Units
: