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 (list of LayoutNode, optional) – Child nodes

  • width (int, str, or Size, optional) – Width specification (default: “auto”)

  • height (int, str, or Size, 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 (int or tuple of int, 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:
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()

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:

SizeConstraints

assign_bounds(x, y, width, height)[source]

Assign bounds to container and position children horizontally.

Supports flexbox-style justify and wrap modes.

Parameters:
  • x (int) – X position

  • y (int) – Y position

  • width (int) – Assigned width

  • height (int) – Assigned height

Return type:

None