helper module

Define functions to be as DRY as possible.

setup_dropdown(module_name: str, base_class: ABCMeta, buttons_args: dict[str, Any]) tuple[dict[str, str], QHBoxLayout, QComboBox, list[QPushButton]]

Set up interface with a dropdown menu and a button next to it.

Parameters:
  • module_name – Where the entries of the dropdown will be searched.

  • base_class – The base class from which dropdown entries should inherit.

  • buttons – Dictionary where the keys are the name of the buttons to add next to the dropdown menu, and values the callable that will be called when clicking the button.

Returns:

  • dict[str, str] – Keys are the name of the objects inheriting from base_class found in module_name. Values are the path leading to them.

  • QHBoxLayout – Layout holding together dropdown and button.

  • QComboBox – Dropdown menu holding the keys of classes.

  • list[QPushButton] – The buttons next to the dropdown menu.

set_dropdown_value(dropdown: QComboBox, value: str | ABCMeta | None) None

Set a dropdown to desired value.

Parameters:
  • dropdown – Dropdown object.

  • value – Name of class or class object you want to select in the dropdown. If unset, we do not do anything.

  • allowed_values – Dict used for the dropdown creation; links name of class objects to their import path.

setup_linspace_entries(label: str, initial_values: tuple[float, float, int], max_value: float | None = None) tuple[QHBoxLayout, QLineEdit, QLineEdit, QLineEdit]

Create an input to call np.linspace.

_linspace_entry(is_int: bool, x_0: float, x_min: int = 0, x_max: float | None = None) QWidget

Create widget for a single linspace entry.

setup_lock_checkbox(parameter: Parameter) QWidget

Create the checkbox for the Lock button.

_toggle_lock(state: Any, parameter: Parameter) None

Activate/deactivate lock.

to_plot_checkboxes(label: str, boxes_labels: Collection[str], *, several_can_be_checked: Literal[False]) tuple[QHBoxLayout, list[QRadioButton]]
to_plot_checkboxes(label: str, boxes_labels: Collection[str], *, several_can_be_checked: Literal[True]) tuple[QHBoxLayout, list[QCheckBox]]

Create several check boxes next to each other.

set_help_button_action(button: QPushButton, obj: Any) None

Update the link of the provided help button.

_open_help(obj: Any) None

Open the doc_url attribute of given object.

format_number(value: int | float) str

Format the given number.

Parameters:

value – Number to format.

PARAMETER_POS_TO_ATTR = {0: 'name', 1: 'unit', 2: 'value', 3: 'lower_bound', 4: 'upper_bound', 5: 'lock'}

Maps column position in list of parameters to the corresponding Parameter attribute