bec_widgets.utils.layout_manager#

Classes#

GridLayoutManager

GridLayoutManager class is used to manage widgets in a QGridLayout and extend its functionality.

Module Contents#

class GridLayoutManager(layout: qtpy.QtWidgets.QGridLayout)#

GridLayoutManager class is used to manage widgets in a QGridLayout and extend its functionality.

The GridLayoutManager class provides methods to add, move, and check the position of widgets in a QGridLayout. It also provides a method to get the positions of all widgets in the layout.

Parameters:

layout (QGridLayout) – The layout to manage.

add_widget(widget: qtpy.QtWidgets.QWidget, row=None, col=0, rowspan=1, colspan=1, shift: Literal['down', 'up', 'left', 'right'] = 'down')#

Add a widget to the layout at the specified position.

Parameters:
  • widget (QWidget) – The widget to add.

  • row (int) – The row to add the widget to. If None, the widget will be added to the next available row.

  • col (int) – The column to add the widget to. Default is 0.

  • rowspan (int) – The number of rows the widget will span. Default is 1.

  • colspan (int) – The number of columns the widget will span. Default is 1.

  • shift (str) – The direction to shift the widgets if the position is occupied. Can be “down”, “up”, “left”, or “right”.

get_widgets_positions() dict#

Get the positions of all widgets in the layout. :returns: A dictionary with the positions of the widgets in the layout. :rtype: dict

is_position_occupied(row: int, col: int) bool#

Check if the position in the layout is occupied by a widget.

Parameters:
  • row (int) – The row to check.

  • col (int) – The column to check.

Returns:

True if the position is occupied, False otherwise.

Return type:

bool

move_widget(widget: qtpy.QtWidgets.QWidget, new_row: int, new_col: int)#

Move a widget to a new position in the layout.

Parameters:
  • widget (QWidget) – The widget to move.

  • new_row (int) – The new row to move the widget to.

  • new_col (int) – The new column to move the widget to.

shift_widgets(direction: Literal['down', 'up', 'left', 'right'] = 'down', start_row: int = 0, start_col: int = 0)#

Shift widgets in the layout in the specified direction starting from the specified position.

Parameters:
  • direction (str) – The direction to shift the widgets. Can be “down”, “up”, “left”, or “right”.

  • start_row (int) – The row to start shifting from. Default is 0.

  • start_col (int) – The column to start shifting from. Default is 0.

layout#