TTkLayout🌢️

class TTkLayout(**kwargs)[source]🌢️

Bases: TTkLayoutItem

The TTkLayout class is the base class of geometry managers. <br/>
It allows free placement of the widgets in the layout area. <br/>
Used mainly to have free range moving TTkWindow because the widgets are not automatically rearranged after a layout event
╔════════════════════════════╗
β•‘   pos(4,2)                 β•‘
β•‘   β”Œβ”€β”€β”€β”€β”€β”€β”€β”   pos(16,4)    β•‘
β•‘   β”‚Widget1β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β•‘
β•‘   β”‚       β”‚   β”‚ Widget2 β”‚  β•‘
β•‘   β”‚       β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β•‘
β•‘   β”‚       β”‚                β•‘
β•‘   β””β”€β”€β”€β”€β”€β”€β”€β”˜                β•‘
β•‘                            β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Methods🌢️

addItem(item)[source]🌢️

Append a layout item.

Parameters:

item (TTkLayoutItem) – item to append

addItems(items)[source]🌢️

Append multiple layout items.

Parameters:

items (list[TTkLayoutItem]) – items to append

addWidget(widget)[source]🌢️

Add a widget to this Layout

Parameters:

widget (TTkWidgets) – the widget to be added

addWidgets(widgets)[source]🌢️

Add a list of widgets to this Layout

Parameters:

widgets (list of TTkWidgets) – the widget to be added

children()[source]🌢️

Return the list of direct child layout items.

clear() → None[source]🌢️

Remove and detach all items from this layout.

count()[source]🌢️

Return the number of direct child layout items.

fullWidgetAreaGeometry()[source]🌢️

Return the bounding geometry that encloses all child items.

Returns:

(x, y, width, height) bounding box

Return type:

tuple[int, int, int, int]

insertItem(index, item)[source]🌢️

Insert a single item at index.

Parameters:
  • index (int) – insertion index

  • item (TTkLayoutItem) – item to insert

insertItems(index, items)[source]🌢️

Insert multiple items at index and re-parent them.

Widgets passed directly are converted to their associated TTkWidgetItem wrapper before insertion.

Parameters:
  • index (int) – insertion index

  • items (list) – items or widgets to insert

insertWidget(index, widget)[source]🌢️

Insert a widget at index.

Parameters:
  • index (int) – insertion index

  • widget (TTkWidgets) – widget to insert

insertWidgets(index, widgets)[source]🌢️

Insert widgets at index.

Parameters:
  • index (int) – insertion index

  • widgets (list of TTkWidgets) – widgets to insert

itemAt(index)[source]🌢️

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

Parameters:

index (int) – child index

Returns:

the layout item at index if available

Return type:

TTkLayoutItem or None

iterWidgets(onlyVisible: bool = True, recurse: bool = True, reverse: bool = False) → Generator[TTkWidget, None, None][source]🌢️

Iterate over all widgets in the layout.

Parameters:
  • onlyVisible (bool) – if True, only yield visible widgets

  • recurse (bool) – if True, recursively iterate through nested layouts

  • reverse (bool) – if True, iterate in reverse order

Returns:

generator yielding widgets

Return type:

Generator[TTkWidget, None, None]

layoutItemType() → LayoutItemTypes[source]🌢️

Return TTkK.LayoutItemTypes.LayoutItem.

lowerWidget(widget)[source]🌢️

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

Parameters:

widget (TTkWidget) – widget to lower

parentWidget() → TTkWidget | None[source]🌢️

Return the widget owning this layout branch.

Returns:

nearest parent widget in the hierarchy

Return type:

TTkWidget or None

raiseWidget(widget)[source]🌢️

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

Parameters:

widget (TTkWidget) – widget to raise

removeItem(item)[source]🌢️

Remove a single layout item.

Parameters:

item (TTkLayoutItem) – item to remove

removeItems(items)[source]🌢️

Remove a list of layout items if present.

Parameters:

items (list[TTkLayoutItem]) – items to remove

removeWidget(widget)[source]🌢️

Remove a widget from this Layout

Parameters:

widget (TTkWidgets) – the widget to be removed

removeWidgets(widgets)[source]🌢️

Remove a list of widget from this Layout

Parameters:

widgets (list of TTkWidgets) – the widget to be removed

replaceItem(item, index)[source]🌢️

Replace the item at index with item.

Parameters:
  • item (TTkLayoutItem) – replacement item

  • index (int) – target index to replace

Raises:

ValueError – if index is outside the valid range

setGeometry(x, y, w, h)[source]🌢️

Set layout geometry and propagate a layout update when changed.

Parameters:
  • x (int) – horizontal position

  • y (int) – vertical position

  • w (int) – width

  • h (int) – height

setParent(parent)[source]🌢️

Set the parent layout item and propagate parent widget ownership.

Parameters:

parent (object) – parent layout item or widget-like owner

update(*args, **kwargs) → None[source]🌢️

Propagate update requests to child widgets and nested layouts.

TTkLayout Attributes🌢️

LAYER0

LAYER1

LAYER2

LAYER3

LAYERMASK

zSortedItems

Return child items sorted by z-order.