helper module

Define functions to be as DRY as possible.

setup_dropdown(module_name, base_class, buttons_args)

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

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

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

  • buttons_args (dict[str, Any]) – 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. Several callables can be provided as a list or tuple.

Return type:

tuple[dict[str, str], QHBoxLayout, QComboBox, list[QPushButton]]

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, value)

Set a dropdown to desired value.

Parameters:
  • dropdown (QComboBox) – Dropdown object.

  • value (str | ABCMeta | None) – 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.

Return type:

None

setup_linspace_entries(label, initial_values, max_value=None)

Create an input to call np.linspace.

Return type:

tuple[QHBoxLayout, QLineEdit, QLineEdit, QLineEdit]

_linspace_entry(is_int, x_0, x_min=0, x_max=None)

Create widget for a single linspace entry.

Return type:

QWidget

setup_lock_checkbox(parameter)

Create the checkbox for the Lock button.

Return type:

QWidget

_toggle_lock(state, parameter)

Activate/deactivate lock.

Return type:

None

to_plot_checkboxes(label, boxes_labels, *, several_can_be_checked=False)

Create several check boxes next to each other.

Return type:

tuple[QHBoxLayout, list[QRadioButton] | list[QCheckBox]]

set_help_button_action(button, obj)

Update the link of the provided help button.

Return type:

None

_open_help(obj)

Open the doc_url attribute of given object.

Return type:

None

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

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