textual.layout
DockArrangeResult
dataclass
¶
Result of Layout.arrange.
Layout
¶
Bases: ABC
Base class of the object responsible for arranging Widgets within a container.
WidgetPlacement
¶
Bases: NamedTuple
The position, size, and relative order of a widget within its parent.
apply_absolute
classmethod
¶
apply_absolute(placements)
Applies absolute offsets (in place).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[WidgetPlacement]
|
A list of placements. |
required |
get_bounds
classmethod
¶
get_bounds(placements)
Get a bounding region around all placements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Iterable[WidgetPlacement]
|
A number of placements. |
required |
Returns:
Type | Description |
---|---|
Region
|
An optimal binding box around all placements. |
process_offset
¶
process_offset(constrain_region, absolute_offset)
Apply any absolute offset or constrain rules to the placement.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Region
|
The container region when applying constrain rules. |
required |
|
Offset
|
Default absolute offset that moves widget in to screen coordinates. |
required |
Returns:
Type | Description |
---|---|
WidgetPlacement
|
Processes placement, may be the same instance. |
translate
classmethod
¶
translate(placements, translate_offset)
Move all non-absolute placements by a given offset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[WidgetPlacement]
|
List of placements. |
required |
|
Offset to add to placements. |
required |
Returns:
Type | Description |
---|---|
list[WidgetPlacement]
|
Placements with adjusted region, or same instance if offset is null. |