ui
pykraken.ui A declarative UI and layout submodule.
At a glance
7 membersReference
PYTHON APIbutton
functionCreate a clickable text button.
The button is evaluated against the previous frame's bounds and returns True when it is clicked during the current frame.
Args
- text (
str) — The label displayed on the button. - style (
Style, optional) — Visual and layout settings for the button.
Returns
- bool — True if the button was clicked this frame, otherwise False.
column
functionCreate a vertical container.
Children are laid out top to bottom unless alignment or spacing overrides are applied on the returned context.
Args
- style (
Style, optional) — Base style for the container. - gap (
float, optional) — Space between child elements. Defaults to 0.0. - padding (
float, optional) — Inner padding of the container. Defaults to 0.0. - align (
Align, optional) — Cross-axis alignment for children. Defaults to Start. - justify (
Align, optional) — Main-axis justification for children. Defaults to Start.
Returns
- _Context — A context manager for the column.
label
functionCreate a non-interactive text label.
Args
- text (
str) — The text to display. - style (
Style, optional) — Visual and layout settings for the label.
panel
functionCreate a non-interactive container element.
Panels draw their background, texture, and borders using the provided style.
root
functionroot(bounds: Rect, direction: ui.Direction = Direction.VERTICAL, align: ui.Align = Align.START, justify: ui.Align = Align.START) -> ui._RootContextCreate a root UI context for the current frame.
The root defines the available bounds for the UI tree and controls the default layout direction and alignment. Use it as a context manager.
Args
- bounds (
Rect) — The available region for the UI. - direction (
Direction, optional) — The root layout direction. Defaults to Vertical. - align (
Align, optional) — Cross-axis alignment for root children. Defaults to Start. - justify (
Align, optional) — Main-axis justification for root children. Defaults to Start.
Returns
- _RootContext — A context manager that finalizes the UI when exited.
row
functionCreate a horizontal container.
Children are laid out left to right unless the active direction or alignment settings are changed on the returned context.
Args
- style (
Style, optional) — Base style for the container. - gap (
float, optional) — Space between child elements. Defaults to 0.0. - padding (
float, optional) — Inner padding of the container. Defaults to 0.0. - align (
Align, optional) — Cross-axis alignment for children. Defaults to Start. - justify (
Align, optional) — Main-axis justification for children. Defaults to Start.
Returns
- _Context — A context manager for the row.
stack
functionCreate an overlapping container.
Stack children share the same container space instead of being arranged in a linear flow.
Args
- style (
Style, optional) — Base style for the container. - padding (
float, optional) — Inner padding of the container. Defaults to 0.0. - align (
Align, optional) — Alignment for children inside the stack. Defaults to Start. - justify (
Align, optional) — Justification for children inside the stack. Defaults to Start.
Returns
- _Context — A context manager for the stack.