wijjit.layout.engine.HStack
- class wijjit.layout.engine.HStack(children=None, width='auto', height='auto', spacing=0, padding=0, margin=0, align_h='stretch', align_v='stretch', justify='flex-start', wrap=False, row_gap=None, column_gap=None, id=None)[source]
Horizontal stacking container.
Arranges children horizontally with optional spacing. Supports flexbox-style features including content justification and wrapping.
- Parameters:
children (
listofLayoutNode, optional) – Child nodeswidth (
int,str, orSize, optional) – Width specification (default: “auto”)height (
int,str, orSize, optional) – Height specification (default: “auto”)spacing (
int, optional) – Spacing between children (default: 0). Acts as column_gap fallback.padding (
int, optional) – Padding around children (default: 0)margin (
intortupleofint, optional) – Margin around container (default: 0)align_h (
{"left", "center", "right", "stretch"}, optional) – Horizontal alignment of children (default: “stretch”)align_v (
{"top", "middle", "bottom", "stretch"}, optional) – Vertical alignment of children (default: “stretch”)justify (
str, optional) – Main axis distribution mode (default: “flex-start”). Options: “flex-start”, “flex-end”, “center”, “space-between”, “space-around”, “space-evenly”, “left”, “right”wrap (
bool, optional) – If True, children wrap to next row when exceeding width (default: False)row_gap (
int, optional) – Space between rows when wrapping (default: 0)column_gap (
int, optional) – Space between columns. Overrides spacing if provided.id (
str, optional) – Node identifier
Notes
When any child has width=”fill”, the justify setting is ignored and fill children expand to consume remaining space instead.
When wrap=True with fill children, fill is treated as auto-sized.
- __init__(children=None, width='auto', height='auto', spacing=0, padding=0, margin=0, align_h='stretch', align_v='stretch', justify='flex-start', wrap=False, row_gap=None, column_gap=None, id=None)[source]
- Parameters:
children (list[LayoutNode] | None)
spacing (int)
align_h (Literal['left', 'center', 'right', 'stretch'])
align_v (Literal['top', 'middle', 'bottom', 'stretch'])
justify (Literal['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly', 'left', 'right'])
wrap (bool)
row_gap (int | None)
column_gap (int | None)
id (str | None)
- Return type:
None
Methods
__init__([children, width, height, spacing, ...])add_child(child)Add a child node.
assign_bounds(x, y, width, height)Assign bounds to container and position children horizontally.
Calculate constraints for horizontal stack.
collect_elements()Collect all elements from children.
get_height_for_width(width)Return the height this node needs when laid out at
width.- calculate_constraints()[source]
Calculate constraints for horizontal stack.
Width is the sum of children widths plus column_gap. Height is the maximum of children heights.
When wrap=True: - min_width is the widest single child (must fit at least one) - preferred_width is single-row width (no wrapping needed)
- Returns:
Calculated constraints
- Return type: