mantidimaging.gui.utility.qt_helpers module#

Module containing helper functions relating to PyQt.

class mantidimaging.gui.utility.qt_helpers.BlockQtSignals(q_objects: QObject | list[QObject])[source]#

Bases: object

Used to block Qt signals from a selection of QWidgets within a context.

class mantidimaging.gui.utility.qt_helpers.Type(value)[source]#

Bases: IntEnum

An enumeration.

BOOL = 8#
BUTTON = 11#
CHOICE = 7#
FLOAT = 5#
INT = 6#
LABEL = 9#
LIST = 4#
NONETYPE = 3#
STACK = 10#
STR = 1#
TUPLE = 2#
mantidimaging.gui.utility.qt_helpers.add_property_to_form(label: str, dtype: Type | str, default_value=None, valid_values=None, tooltip=None, on_change=None, form=None, filters_view=None, run_on_press=None, single_step_size=None) tuple[QLabel | QLineEdit, Any][source]#

Adds a property to the algorithm dialog.

Handles adding basic data options to the UI.

Parameters:
  • label – Label that describes the option

  • dtype – Option data type (any of: file, int, float, bool, list)

  • default_value – Optionally select the default value

  • valid_values – Optionally provide the range or selection of valid values

  • tooltip – Optional tooltip text to show on property

  • on_change – Function to be called when the property changes

  • form – Form layout to optionally add the new widgets to

  • filters_view – The Filter window view - passed to connect Type.STACK to the stack change events

  • run_on_press – Run this function on press, specialisation for button.

  • single_step_size – Optionally provide a step size for a SpinBox widget.

mantidimaging.gui.utility.qt_helpers.compile_ui(ui_file, qt_obj=None)[source]#
mantidimaging.gui.utility.qt_helpers.delete_all_widgets_from_layout(lo)[source]#

Removes and deletes all child widgets form a layout.

Parameters:

lo – Layout to clean

mantidimaging.gui.utility.qt_helpers.get_value_from_qwidget(widget: QWidget)[source]#
mantidimaging.gui.utility.qt_helpers.on_change_and_disable(widget: QWidget, on_change: Callable)[source]#

Makes sure the widget is disabled while running the on_update method. This is required for spin boxes that continue increasing when generating a preview image is computationally intensive. :param widget: The widget to disable. :param on_change: The method to call when the widget has been changed.

mantidimaging.gui.utility.qt_helpers.populate_menu(menu: QMenu, actions_list: list[QAction])[source]#
mantidimaging.gui.utility.qt_helpers.select_directory(field, caption)[source]#