Layouts¶
Functions that fill a control's frame with evenly divided children. See Layouts in the guide for how they compose.
row ¶
row(
parent: Control,
control_type: ControlType | str = ControlType.GROUP,
*,
sizes: int | Sequence[float] = 3,
colors: tuple[object, object] | None = None,
) -> list[Control]
Lay controls out horizontally, filling the parent's frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Control
|
The control to fill. Its frame sets the available space. |
required |
control_type
|
ControlType | str
|
The type of control to create. |
GROUP
|
sizes
|
int | Sequence[float]
|
How many slots, or their relative widths. |
3
|
colors
|
tuple[object, object] | None
|
Two endpoints for a left-to-right gradient. |
None
|
Returns:
| Type | Description |
|---|---|
list[Control]
|
The created controls, left to right, already added to |
Source code in src/py2tosc/layout.py
column ¶
column(
parent: Control,
control_type: ControlType | str = ControlType.GROUP,
*,
sizes: int | Sequence[float] = 3,
colors: tuple[object, object] | None = None,
) -> list[Control]
Stack controls vertically, filling the parent's frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Control
|
The control to fill. Its frame sets the available space. |
required |
control_type
|
ControlType | str
|
The type of control to create. |
GROUP
|
sizes
|
int | Sequence[float]
|
How many slots, or their relative heights. |
3
|
colors
|
tuple[object, object] | None
|
Two endpoints for a top-to-bottom gradient. |
None
|
Returns:
| Type | Description |
|---|---|
list[Control]
|
The created controls, top to bottom, already added to |
Source code in src/py2tosc/layout.py
matrix ¶
matrix(
parent: Control,
control_type: ControlType | str = ControlType.GROUP,
*,
columns: int = 4,
rows: int = 4,
colors: tuple[object, object] | None = None,
direction: str = "horizontal",
) -> list[Control]
Tile controls in a grid, filling the parent's frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Control
|
The control to fill. Its frame sets the available space. |
required |
control_type
|
ControlType | str
|
The type of control to create. |
GROUP
|
columns
|
int
|
How many columns. |
4
|
rows
|
int
|
How many rows. |
4
|
colors
|
tuple[object, object] | None
|
Two endpoints for the gradient. |
None
|
direction
|
str
|
How the gradient runs across the grid -- |
'horizontal'
|
Returns:
| Type | Description |
|---|---|
list[Control]
|
The created controls in row-major order, already added to |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/py2tosc/layout.py
gradient ¶
Interpolate count colours between two endpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
object
|
The first colour, in any notation |
required |
end
|
object
|
The last colour. |
required |
count
|
int
|
How many colours to produce. Must be at least 1. |
required |
Returns:
| Type | Description |
|---|---|
list[Color]
|
The interpolated colours, |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |