FlowLayout

class MangoUI.FlowLayout.FlowLayout(parent=None, margin=0, spacing=- 1)

Flow layout widget, as outlined in the official Qt documentation and implemented by Tong Xiao.

https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html https://gist.github.com/Cysu/7461066

Parameters
  • parent (PyQt6.QtCore.QObject, optional) – Parent object that contains this widget. Passing this ensures that destroying the parent also destroys this widget.

  • margin (int) – Left, right, top, and bottom margins for layout.

  • spacing (int) – Spacing between child widgets.

addItem(item)

Add widget to layout.

Parameters

item (PyQt6.QtCore.QObject) – Item to add.

count()

Get number of items.

Returns

Number of items.

Return type

int

doLayout(rect, testOnly)

Layout all items.

Parameters
  • rect (PyQt6.QtCore.QRect) – Left, top, width, and height values.

  • testOnly (bool) – Indicates if layout should be created.

Returns

Height of layout.

Return type

int

expandingDirections()

Returns whether this layout can make use of more space than sizeHint indicates.

Returns

Indicates whether this layout can make use of more space.

Return type

PyQt6.QtCore.Qt.Orientation

hasHeightForWidth()

Returns True if this layout’s preferred height depends on its width; otherwise returns False.

Returns

Indicates if height depends on width.

Return type

bool

heightForWidth(width)

Returns the preferred height for this layout item, given the width, which is not used in this default implementation.

Parameters

width (int) – Given width.

Returns

Preferred height.

Return type

int

itemAt(idx)

Get item by index.

Parameters

idx (int) – Item index.

Returns

Found item.

Return type

PyQt6.QtCore.QObject

minimumSize()

Get the widget’s minimum size.

Returns

Minimum size.

Return type

PyQt6.QtCore.QSize

setGeometry(rect)

Set geometry of the widget relative to its parent and excluding the window frame.

Parameters

rect (PyQt6.QtCore.QRect) – Left, top, width, and height values.

sizeHint()

Get the recommended size for the widget.

Returns

Recommended size.

Return type

PyQt6.QtCore.QSize

takeAt(idx)

Pop item by index.

Parameters

idx (int) – Item index.

Returns

Popped item.

Return type

PyQt6.QtCore.QObject