spacr.qt.widgets.flow¶
A left-to-right layout that wraps, and the widget that hosts one.
Lifted out of spacr.qt.screens.settings_model, where it was written for
the settings panel’s chip strip, because a wrapping row is not a settings
idea: the regression results header wants one too. Three combo boxes with
minimum widths, a run name of unpredictable length and a QHBoxLayout do not
fit in a narrow panel, and Qt’s answer to a box it cannot satisfy is to let
the children overlap – measured at 577 px, where the second box started
48 px inside the first and the third ran 32 px off the panel.
Classes¶
The widget a |
|
A left-to-right layout that wraps onto a new line when it runs out. |
Module Contents¶
- class spacr.qt.widgets.flow.FlowHost(parent=None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetThe widget a
FlowLayoutlives in.Qt only consults a layout’s
heightForWidththrough the widget that owns it, and only when that widget’s size policy says its height depends on its width. Without this the strip reported a one-line height however many chips it held, andcontrols(thirty of them) drew off the edge of the settings column instead of wrapping.- Parameters:
parent – parent widget.
Create a widget that reports its height from its width.
Height-for-width is enabled explicitly: without it a wrapping layout’s extra lines are never given room and the last row is clipped.
- Parameters:
parent – parent widget, or
None.
- class spacr.qt.widgets.flow.FlowLayout(parent=None, spacing: int = 4)[source]¶
Bases:
PySide6.QtWidgets.QLayoutA left-to-right layout that wraps onto a new line when it runs out.
Chips have to wrap:
controlsships thirty of them and a horizontal box would either clip them or force the settings panel wider than the window.- Parameters:
parent – parent widget.
spacing – pixels between chips, horizontally and vertically.
Create a layout that wraps its items onto new lines.
- Parameters:
parent – the widget to lay out, or
None.spacing – gap between items, horizontally and vertically.
- addItem(item) None[source]¶
Append a layout item (Qt calls this for every added widget).
- Parameters:
item – the
QLayoutItemto append after the existing items.
- heightForWidth(width: int) int[source]¶
Height needed to lay the chips out inside
width.- Parameters:
width – available width in pixels; the items are wrapped into it without being moved.
- itemAt(index)[source]¶
Return the item at
index, or None when out of range.- Parameters:
index – zero-based position of the item.
- setGeometry(rect) None[source]¶
Place every chip inside
rect.- Parameters:
rect – the
QRectgiven to the layout; the items are wrapped and placed inside it.