bec_widgets.utils.container_utils#

Classes#

Module Contents#

class WidgetContainerUtils#
static find_first_widget_by_class(container: dict, widget_class: Type[qtpy.QtWidgets.QWidget], can_fail: bool = True) qtpy.QtWidgets.QWidget | None#

Find the first widget of a given class in the figure.

Parameters:
  • container (dict) – The container of widgets.

  • widget_class (Type) – The class of the widget to find.

  • can_fail (bool) – If True, the method will return None if no widget is found. If False, it will raise an error.

Returns:

The widget of the given class.

Return type:

widget

static generate_unique_name(name: str, list_of_names: list[str] | None = None) str#

Generate a unique ID.

Parameters:

name (str) – The name of the widget.

Returns:

The unique name

Return type:

tuple (str)

static has_name_valid_chars(name: str) bool#

Check if the name is valid.

Parameters:

name (str) – The name to be checked.

Returns:

True if the name is valid, False otherwise.

Return type:

bool

static name_is_protected(name: str, container: Any = None) bool#

Check if the name is not protected.

Parameters:

name (str) – The name to be checked.

Returns:

True if the name is not protected, False otherwise.

Return type:

bool

static raise_for_invalid_name(name: str, container: Any = None) None#

Check if the name is valid. If not, raise a ValueError.

Parameters:

name (str) – The name to be checked.

Raises:

ValueError – If the name is not valid.