pyboxbuilder.compartments.sizing.distribute_row_width

pyboxbuilder.compartments.sizing.distribute_row_width(items: list[RowItem], available_width: float, gap: float = 2.0) → list[tuple[str, float, float]][source]

Grow the growable items in a row so the row fills available_width.

Slack is shared in proportion to each growable item’s current width, so a wide well absorbs more of the leftover than a narrow one and the row keeps its visual rhythm.

Parameters:
items: list[RowItem]

Compartments in the row, in placement order.

available_width: float

Interior width the row must fill, in mm.

gap: float = 2.0

Spacing between adjacent compartments and at both ends, in mm.

Returns:

(label, width, length) per item, in the same order, at 0.1 mm precision.

Raises:

ValueError – If the items cannot fit in available_width at all.