Reference

Garnet

Main Qt application

garnet.garnet.gui()[source]

Open main entry point for Qt application

Home

Presenter for the Home tab

class garnet.home.presenter.HomePresenter(view: HomeView, model: HomeModel)[source]

Home presenter

Parameters:
  • view (HomeView) – The view for this presenter

  • model (HomeModel) – The model for this presenter

property model: HomeModel

Return the model for this presenter

property view: HomeView

Return the view for this presenter

PyQt widget for the home tab

class garnet.home.view.HomeView(*args: Any, **kwargs: Any)[source]

Home widget

Parameters:

QWidget (QWidget) – The main widget

save_reduction_plan() None[source]

Save reduction plan

update_button_status(error_text: Dict[str, str] | None = None)[source]

Update the status of the save button based on the presence of invalid fields and error messages.

Parameters:

error_text – Dictionary of error messages for specific fields.

The save button will be enabled only if there are no invalid fields and no error messages.

update_plan_name()[source]

Update the plan name field.

If the plan name is empty, set the style to indicate an invalid field with a red border, add an error message to the status bar, and disable the save button. Otherwise, clear the style, remove the error message from the status bar, and enable the save button.

update_wavelength()[source]

Update the wavelength field.

If the input cannot be converted to a float, set the style to indicate an invalid field with a red border, add an error message to the status bar, and disable the save button. Otherwise, clear the style, remove the error message from the status bar, and enable the save button.

Model for the Home tab

class garnet.home.model.HomeModel[source]

Home model

Base Qt Objects

BaseLineEdit

This module defines the BaseLineEdit class, a customized QLineEdit with setup and helper functions for QLineEdits used in Garnet.

class garnet.helpers.ui_elements.base_lineedit.BaseLineEdit(*args: Any, **kwargs: Any)[source]

BaseLineEdit that inherits the QLineEdit.

This class includes setup and helper functions for QLineEdits used in Garnet.

Parameters:
  • required (bool, optional) – Indicate whether the field is required. Defaults to False.

  • default_value (Any, optional) – Set the default value for the field. Defaults to None.

  • parent (Any, optional) – The parent object that holds the QLineEdit. Defaults to None.

  • args – Additional positional arguments that will be passed to the parent class constructor.

  • kwargs – Additional keyword arguments that will be passed to the parent class constructor.

reset_style() None[source]

Reset the style to its default.

set_empty_style() None[source]

Once the field has been validated, the style will be cleared.

set_invalid_style() None[source]

Set field style as invalid

If a validator determines the field is invalid, this function will be called and the field will be marked with a red border.

set_required_style() None[source]

If a field is required, the background will be set to light-yellow.

BaseStatusBar

This module defines the BaseStatusBar class, a custom status bar for PyQt applications. The BaseStatusBar provides functionality for displaying error messages and additional information through QLabel widgets. It includes methods to update the status label with error messages and the CWE (Caution, Warnings or Error) label with relevant information.

class garnet.helpers.ui_elements.base_statusbar.BaseStatusBar(*args: Any, **kwargs: Any)[source]

Custom status bar for displaying error messages and additional information.

update_cwe_label(text: str) None[source]

Update the cwe_label with the provided text.

Parameters:

text (str) – The text to be displayed in the Caution, Warning, Error label.

update_status_label(error_text: Dict[object, str] | None = None) bool[source]

Update the status_label with the provided error_text.

Parameters:

error_text (Dict[object, str], optional) – Dictionary of error messages. Defaults to None.

Return bool:

True if there are any invalid entries, False otherwise.

BaseTableWidget

This module defines the BaseTableWidget class, a customized QTableWidget with setup and helper functions for QTableWidgets used in Garnet.

class garnet.helpers.ui_elements.base_tablewidget.BaseTableWidget(*args: tuple[Any], required: bool | None = False, **kwargs: dict[str, Any])[source]

BaseTableWidget that inherits the QTableWidget.

This class includes setup and helper functions for QTableWidgets used in Garnet.

Parameters:
  • required (bool, optional) – Indicate whether the field is required. Defaults to False.

  • parent (Any, optional) – The parent object that holds the QTableWidget. Defaults to None.

  • args – Additional positional arguments that will be passed to the parent class constructor.

  • kwargs – Additional keyword arguments that will be passed to the parent class constructor.

reset_style() None[source]

Reset the style to its default.

set_empty_style() None[source]

Once the field has been validated, the style will be cleared.

set_invalid_style() None[source]

Set field style as invalid.

If a validator determines the field is invalid, this function will be called and the field will be marked with a red border.

set_required_style() None[source]

If a field is required, the background will be set to light-yellow.

BaseCheckBox

This module defines the BaseCheckBox class, a customized QCheckBox with setup and helper functions for QCheckBoxes used in Garnet.

class garnet.helpers.ui_elements.base_checkbox.BaseCheckBox(*args: tuple[Any], required: bool | None = False, **kwargs: dict[str, Any])[source]

BaseCheckBox that inherits the QCheckBox.

This class includes setup and helper functions for QCheckBoxes used in Garnet.

Parameters:
  • required (bool, optional) – Indicate whether the field is required. Defaults to False.

  • parent (Any, optional) – The parent object that holds the QCheckBox. Defaults to None.

  • args – Additional positional arguments that will be passed to the parent class constructor.

  • kwargs – Additional keyword arguments that will be passed to the parent class constructor.

reset_style() None[source]

Reset the style to its default.

set_empty_style() None[source]

Once the field has been validated, the style will be cleared.

set_invalid_style() None[source]

Set field style as invalid.

If a validator determines the field is invalid, this function will be called and the field will be marked with a red color.

set_required_style() None[source]

If a field is required, the text color will be set to blue.

BaseListWidget

This module defines the BaseListWidget class, a customized QListWidget with setup and helper functions for QListWidgets used in Garnet.

class garnet.helpers.ui_elements.base_listwidget.BaseListWidget(*args: tuple[Any], required: bool | None = False, **kwargs: dict[str, Any])[source]

BaseListWidget that inherits the QListWidget.

This class includes setup and helper functions for QListWidgets used in Garnet.

Parameters:
  • required (bool, optional) – Indicate whether the field is required. Defaults to False.

  • parent (Any, optional) – The parent object that holds the QListWidget. Defaults to None.

  • args – Additional positional arguments that will be passed to the parent class constructor.

  • kwargs – Additional keyword arguments that will be passed to the parent class constructor.

When creating a BaseListWidget, also pay attention to the selection mode. The selection mode will change the behavior of the list widget when selecting items. The selection mode can be set using the setSelectionMode method.

param mode:

Selection mode to be set. 0: NoSelection 1: SingleSelection 2: MultiSelection 3: ExtendedSelection 4: ContiguousSelection

type mode:

int

more info about the selection mode can be found in the Qt documentation

reset_style() None[source]

Reset the style to its default.

set_empty_style() None[source]

Once the field has been validated, the style will be cleared.

set_invalid_style() None[source]

Set field style as invalid.

If a validator determines the field is invalid, this function will be called and the field will be marked with a red border.

set_required_style() None[source]

If a field is required, the background will be set to light-yellow.