TTkGridLayout๐ŸŒถ๏ธ

class TTkGridLayout(*, columnMinWidth: int = 0, rowMinHeight: int = 0, **kwargs)[source]๐ŸŒถ๏ธ

Bases: TTkLayout

The grid layout allows an automatic place all the widgets in a grid, <br/> the empty rows/cols are resized to the โ€œrowMinHeight,columnMinWidthโ€ parameters

TTkGridLayout        โ”Œโ” columnMinWidth
 โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
 โ•‘ Widget1 โ”‚ Widget2 โ”‚โ”‚ Widget3 โ•‘
 โ•‘ (0,0)   โ”‚ (0,1)   โ”‚โ”‚ (0,3)   โ•‘
 โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข โ” rowMinHeight
 โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข โ”˜
 โ•‘ Widget4 โ”‚         โ”‚โ”‚         โ•‘
 โ•‘ (2,0)   โ”‚         โ”‚โ”‚         โ•‘
 โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
 โ•‘         โ”‚         โ”‚โ”‚ Widget5 โ•‘
 โ•‘         โ”‚         โ”‚โ”‚ (3,3)   โ•‘
 โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
Parameters:
  • columnMinWidth (int) โ€“ the minimum width of the column, optional, defaults to 0

  • rowMinHeight (int) โ€“ the minimum height of the row, optional, defaults to 0

Slots๐ŸŒถ๏ธ

Methods๐ŸŒถ๏ธ

columnMinWidth()[source]๐ŸŒถ๏ธ

Return the minimum width used for empty columns.

getSizes()[source]๐ŸŒถ๏ธ

Return cached horizontal and vertical slot sizes.

Returns:

(horSizes, verSizes)

Return type:

tuple[list, list]

gridItems()[source]๐ŸŒถ๏ธ

Return the internal 2D grid matrix of layout items.

gridSize()[source]๐ŸŒถ๏ธ

Return current allocated grid size as (rows, cols).

insertColumn(col)[source]๐ŸŒถ๏ธ

Insert an empty column at col and shift items to the right.

Parameters:

col (int) โ€“ column index where the new column is inserted

insertRow(row)[source]๐ŸŒถ๏ธ

Insert an empty row at row and shift items downward.

Parameters:

row (int) โ€“ row index where the new row is inserted

itemAtPosition(row: int, col: int)[source]๐ŸŒถ๏ธ

Return the item occupying (row, col).

Spanned items are returned for any covered cell.

Parameters:
  • row (int) โ€“ grid row

  • col (int) โ€“ grid column

Returns:

layout item at this position

Return type:

TTkLayoutItem or None

maximumColWidth(gridCol: int) → int[source]๐ŸŒถ๏ธ

Return the maximum width allowed for a column.

Parameters:

gridCol (int) โ€“ column index

Returns:

maximum column width

Return type:

int

maximumHeight() → int[source]๐ŸŒถ๏ธ

Return the layout maximum height from all grid rows.

maximumRowHeight(gridRow: int)[source]๐ŸŒถ๏ธ

Return the maximum height allowed for a row.

Parameters:

gridRow (int) โ€“ row index

Returns:

maximum row height

Return type:

int

maximumWidth() → int[source]๐ŸŒถ๏ธ

Return the layout maximum width from all grid columns.

minimumColWidth(gridCol: int) → int[source]๐ŸŒถ๏ธ

Return the minimum width required for a column.

Parameters:

gridCol (int) โ€“ column index

Returns:

minimum column width

Return type:

int

minimumHeight() → int[source]๐ŸŒถ๏ธ

Return the layout minimum height from all grid rows.

minimumRowHeight(gridRow: int)[source]๐ŸŒถ๏ธ

Return the minimum height required for a row.

Parameters:

gridRow (int) โ€“ row index

Returns:

minimum row height

Return type:

int

minimumWidth() → int[source]๐ŸŒถ๏ธ

Return the layout minimum width from all grid columns.

repack()[source]๐ŸŒถ๏ธ

Remove empty rows/columns and compact item row/column indices.

rowMinHeight()[source]๐ŸŒถ๏ธ

Return the minimum height used for empty rows.

setColumnMinWidth(cmw)[source]๐ŸŒถ๏ธ

Set the minimum width used for empty columns.

Parameters:

cmw (int) โ€“ minimum empty-column width

setRowMinHeight(rmh)[source]๐ŸŒถ๏ธ

Set the minimum height used for empty rows.

Parameters:

rmh (int) โ€“ minimum empty-row height

Methods Inherited from: TTkLayout

addItem(item[,ย row,ย col,ย rowspan,ย colspan,ย ...])

Add the item to this TTkGridLayout

addItems(items[,ย row,ย col,ย rowspan,ย ...])

Add the items to this TTkGridLayout

addWidget(widget[,ย row,ย col,ย rowspan,ย ...])

Add the widget to this TTkGridLayout, this function uses addItem()

addWidgets(widgets[,ย row,ย col,ย rowspan,ย ...])

Add the widgets to this TTkGridLayout, this function uses addItem()

children()

Return the list of direct child layout items.

clear()

Remove and detach all items from this layout.

count()

Return the number of direct child layout items.

fullWidgetAreaGeometry()

Return the bounding geometry that encloses all child items.

insertItem(index,ย item)

Insert a single item at index.

insertItems(index,ย items)

Insert multiple items at index and re-parent them.

insertWidget(index,ย widget)

Insert a widget at index.

insertWidgets(index,ย widgets)

Insert widgets at index.

itemAt(index)

Return the item at index or None when out of range.

iterWidgets([onlyVisible,ย recurse,ย reverse])

Iterate over all widgets in the layout.

layoutItemType()

Return TTkK.LayoutItemTypes.LayoutItem.

lowerWidget(widget)

Lower a widget (and its branch) to the bottom z-order.

parentWidget()

Return the widget owning this layout branch.

raiseWidget(widget)

Raise a widget (and its branch) to the top z-order.

removeItem(item)

Remove a single layout item from the grid.

removeItems(items)

Remove multiple layout items and clear their grid cells.

removeWidget(widget)

Remove a single widget from the grid.

removeWidgets(widgets)

Remove multiple widgets from the grid.

replaceItem(item,ย index)

Not implemented for grid layout indexed replacement.

setGeometry(x,ย y,ย w,ย h)

Set layout geometry and propagate a layout update when changed.

setParent(parent)

Set the parent layout item and propagate parent widget ownership.

update(*args,ย **kwargs)

Recompute cell geometry and update child widgets/layouts.

TTkGridLayout Attributes๐ŸŒถ๏ธ

LAYER0

LAYER1

LAYER2

LAYER3

LAYERMASK

zSortedItems

Return child items sorted by z-order.