midrc_react.gui.pyside6 package

Submodules

midrc_react.gui.pyside6.columnselectordialog module

This module contains the ColumnSelectorDialog and NumericColumnSelectorDialog classes for selecting columns in a GUI.

class midrc_react.gui.pyside6.columnselectordialog.ColumnSelectorDialog(columns, parent=None, exclusive=False, max_length=25, rows_per_column=10)

Bases: QDialog

Dialog window for displaying and editing column selections.

The checkboxes are displayed in a grid layout inside a scroll area to support a large number of columns. If a column name is longer than max_length characters, a shortened version is displayed with a tooltip showing the full column name.

__init__(columns, parent=None, exclusive=False, max_length=25, rows_per_column=10)

Initialize the ColumnSelectorDialog object.

Parameters:
  • columns (list) – A list of column names.

  • parent (QWidget, optional) – The parent widget. Defaults to None.

  • exclusive (bool, optional) – Whether to use an exclusive button group. Defaults to False.

  • max_length (int, optional) – Maximum characters to display before shortening the label.

  • rows_per_column (int, optional) – Number of checkboxes per column.

get_selected_columns()

Return a list of selected columns.

class midrc_react.gui.pyside6.columnselectordialog.NumericColumnSelectorDialog(columns, parent=None)

Bases: QDialog

Dialog window for displaying and editing numeric column settings.

This class represents a dialog window that allows the user to select numeric columns and set binning parameters. It inherits from the QDialog class provided by the PySide6.QtWidgets module.

Variables:
  • layout (QVBoxLayout) – The layout of the dialog.

  • column_settings (dict) – A dictionary containing the checkbox, min_input, max_input, and step_input widgets.

  • button_box (QDialogButtonBox) – The button box containing the OK and Cancel buttons.

__init__(columns, parent=None)

Initialize the NumericColumnSelectorDialog object.

Parameters:
  • columns (list) – A list of column names.

  • parent (QWidget, optional) – The parent widget of the dialog. Defaults to None.

get_selected_columns_with_bins()

Return a dictionary of selected columns with their bin settings.

Returns:

keys are the target string column names; values are tuples

(raw column, bins, labels) where labels is None.

Return type:

dict

static toggle_inputs(checked, widgets: list[QWidget])

Toggle the visibility of the min, max, and step inputs based on the checkbox state.

Parameters:
  • checked (bool) – The state of the checkbox.

  • widgets (list[QWidget]) – A list of input widgets to toggle.

midrc_react.gui.pyside6.copyabletableview module

This module contains a custom QTableView subclass that allows copying selected data to the clipboard.

class midrc_react.gui.pyside6.copyabletableview.CopyableTableView

Bases: QTableView

Custom QTableView subclass that allows copying selected data to the clipboard.

__init__() None

Initialize the CopyableTableView and install its event filter.

copy_selection() None

Copy the currently selected table data to the clipboard in a tab-delimited format.

Returns:

None

eventFilter(source: QObject, event: QEvent) bool

Filter events to handle key presses for copying selection.

Parameters:
  • source (QObject) – The source object.

  • event (QEvent) – The event to filter.

Returns:

True if the event was handled, False otherwise.

Return type:

bool

midrc_react.gui.pyside6.dataselectiongroupbox module

This module contains the JsdDataSelectionGroupBox class, which is a custom widget for selecting data files and categories in a graphical user interface (GUI) using PySide6.

class midrc_react.gui.pyside6.dataselectiongroupbox.JsdDataSelectionGroupBox(data_sources)

Bases: QGroupBox, GroupBoxData

This class represents a group box widget for data selection. It provides functionality for creating labels and combo boxes for data files and a category combo box. The class has methods for setting up the layout, updating the category combo box, and initializing the widget.

Variables:
  • num_data_items_changed (Signal) – A signal emitted when the number of data items in the JsdDataSelectionGroupBox changes.

  • file_checkbox_state_changed (Signal) – A signal emitted when the state of a file checkbox changes.

  • NUM_DEFAULT_DATA_ITEMS (int) – The default number of data items.

NUM_DEFAULT_DATA_ITEMS: int = 2
__init__(data_sources)

Initialize the JsdDataSelectionGroupBox.

This method sets up the data selection group box by creating labels and combo boxes for data files and a category combo box.

Parameters:

data_sources (list) – A list of data sources.

add_file_combobox_to_layout(auto_populate: bool = True)

Add a file combobox to the layout.

Parameters:

auto_populate (bool) – If True, the combobox will be populated with items from the first combobox.

Returns:

None

add_file_to_comboboxes(description: str, name: str)

Add a file to the file comboboxes.

This method adds a file to each of the file comboboxes in the JsdDataSelectionGroupBox. The file is represented by a description and a name. The description is displayed in the combobox as the item text, and the name is stored as the item data.

Parameters:
  • description (str) – The description of the file.

  • name (str) – The name of the file.

Returns:

None

file_checkbox_state_changed: Signal
get_category_info()

Get the category information and current category.

Returns:

A dictionary containing the category information.

Return type:

dict

get_file_infos()

Get the file information for all files.

Returns:

A list of dictionaries containing information about each file.

Return type:

List[dict]

num_data_items_changed: Signal
remove_file_combobox_from_layout()

Remove a file combobox from the layout.

This method removes the last file combobox from the layout, including its corresponding label. It updates the form layout by removing the row at the specified index. It also removes the label and combobox from the respective lists.

Returns:

None

set_layout(data_sources)

Set the layout for the given data sources.

Parameters:

data_sources – A list of data sources.

Returns:

None

set_num_data_items(count: int)

Set the number of data items in the JsdDataSelectionGroupBox.

This method adjusts the number of file comboboxes in the layout based on the given count.

  • If the current number of file comboboxes is equal to the count, the method returns without making any changes.

  • If the current number of file comboboxes is less than the count, the method adds file comboboxes to the layout using the add_file_combobox_to_layout method.

  • If the current number of file comboboxes is greater than the count, the method removes file comboboxes from the layout using the remove_file_combobox_from_layout method.

  • Finally, the method emits the num_data_items_changed signal with the updated count.

Parameters:

count (int) – The desired number of data items.

Returns:

None

update_category_list(categorylist, categoryindex)

Update the category combo box with the given category list and set the selected index to the specified category index.

Parameters:
  • categorylist (list) – The list of categories to populate the combo box.

  • categoryindex (int) – The index of the category to select in the combo box.

Returns:

None

midrc_react.gui.pyside6.file_open_dialogs module

Module for file open dialogs using PySide6.

This module provides dialogs for opening Excel and CSV/TSV files along with options dialogs. The dialogs support file-specific persistence via QSettings, plugin processing, and column selection.

class midrc_react.gui.pyside6.file_open_dialogs.BaseFileOptionsDialog(parent: QWidget | None, file_name: str)

Bases: QDialog

Base dialog window for displaying and editing file options.

Provides common functionality such as setting the default window title and base name from the file.

__init__(parent: QWidget | None, file_name: str) None

Initialize the base file options dialog.

Parameters:
  • parent (Optional[QWidget]) – The parent widget.

  • file_name (str) – The full path of the file.

class midrc_react.gui.pyside6.file_open_dialogs.CSVTSVOptionsDialog(parent: QWidget | None, file_name: str, available_columns: List[str] | None = None)

Bases: BaseFileOptionsDialog

Dialog for editing CSV/TSV file options with plugin processing.

Provides file-specific persistence and a fallback to last used settings.

__init__(parent: QWidget | None, file_name: str, available_columns: List[str] | None = None) None

Initialize the CSV/TSV options dialog.

Parameters:
  • parent (Optional[QWidget]) – The parent widget.

  • file_name (str) – The file path.

  • available_columns (Optional[List[str]]) – The list of available columns.

accept() None

Override accept to save defaults before closing the dialog.

get_data() Dict[str, Any]

Retrieve all user selections from the dialog.

Returns:

A dictionary containing file metadata and user selections.

Return type:

Dict[str, Any]

load_defaults() None

Load saved options for this file from QSettings.

If no file-specific settings are found, load the last used settings.

open_column_selector() None

Open a dialog for selecting columns to use and pre-select items based on the text edit.

open_numeric_column_selector() None

Open a dialog for selecting numeric columns and binning parameters. Pre-select items based on either the YAML config or the current columns text.

process_plugin() None

Process the file with the selected plugin (if any) and update available columns. The plugin selection controls are locked after processing. Instead of popups, text is displayed in the plugin status label.

save_defaults() None

Save current dialog options to QSettings for both file-specific and last used settings.

class midrc_react.gui.pyside6.file_open_dialogs.FileOptionsDialog(parent: QWidget | None, file_name: str)

Bases: BaseFileOptionsDialog

Dialog window for displaying and editing Excel file options.

__init__(parent: QWidget | None, file_name: str) None

Initialize the FileOptionsDialog for an Excel file.

Parameters:
  • parent (Optional[QWidget]) – The parent widget.

  • file_name (str) – The Excel file path.

midrc_react.gui.pyside6.file_open_dialogs.get_csv_tsv_columns(file_name: str) List[str]

Extract and return the header row (column names) from a CSV or TSV file.

Parameters:

file_name (str) – The path to the CSV/TSV file.

Returns:

A list of column names. Returns an empty list if reading fails.

Return type:

List[str]

midrc_react.gui.pyside6.file_open_dialogs.open_csv_tsv_file_dialog(self: Any) None

Open a file dialog to select a CSV or TSV file and show its options dialog.

This function reads the header row to obtain available columns, then opens the CSVTSVOptionsDialog. It then validates and collects user selections and emits a data source dictionary.

midrc_react.gui.pyside6.file_open_dialogs.open_excel_file_dialog(self: Any) None

Open a file dialog to select an Excel file and show its options dialog.

Emits a data source dictionary via self.add_data_source and updates UI elements via self._dataselectiongroupbox.

midrc_react.gui.pyside6.file_open_dialogs.open_yaml_input_dialog(self: Any) None

Open a dialog to paste YAML content and add it as a data source.

The dialog loads previously saved YAML content (if available) and saves the current input upon acceptance.

midrc_react.gui.pyside6.file_open_dialogs.represent_list(dumper, data)

Represent lists in flow style (inline with square brackets)

Parameters:
  • dumper – The YAML dumper.

  • data – The list to represent.

midrc_react.gui.pyside6.grabbablewidget module

This module provides a mixin class for adding snapshot (grab) and save functionalities to a QWidget.

class midrc_react.gui.pyside6.grabbablewidget.GrabbableChartView(chart: QChart, parent: QWidget | None = None, save_file_prefix: str = 'MIDRC-REACT_plot_')

Bases: QChartView

Subclass of QChartView for creating a chart view that can be grabbed and saved as an image.

Inherits functionality from QChartView and adds the ability to save the chart as an image.

__init__(chart: QChart, parent: QWidget | None = None, save_file_prefix: str = 'MIDRC-REACT_plot_') None

Initialize the class instance with an optional parent QWidget, a save file prefix, and a GrabbableWidgetMixin.

Parameters:
  • chart (QChart) – The chart to be displayed in the view.

  • parent (Optional[QWidget]) – The optional parent QWidget for the chart view.

  • save_file_prefix (str) – The prefix for save file names.

Connect context menu signals for the parent widget to show the context menu and handle events.

save_chart_to_disk()

Save the chart view to disk using the save_to_disk functionality from GrabbableWidgetMixin.

Returns:

None

class midrc_react.gui.pyside6.grabbablewidget.GrabbableWidgetMixin(parent: QWidget = None, save_file_prefix: str = 'MIDRC-REACT_plot_')

Bases: QObject

Mixin class for adding snapshot (grab) and save functionalities to a QWidget.

Variables:
  • DEFAULT_SAVE_FILE_PREFIX (str) – Default prefix for save file names.

  • DATE_TIME_FORMAT (str) – The datetime format for appending to default filenames when saving snapshots

  • save_dialog_open (bool) – Indicates if the save dialog is currently open.

DATE_TIME_FORMAT = 'yyyyMMddhhmmss'
DEFAULT_SAVE_FILE_PREFIX = 'MIDRC-REACT_plot_'
__init__(parent: QWidget = None, save_file_prefix: str = 'MIDRC-REACT_plot_') None

Initialize the class instance with optional parent QWidget and a save file prefix. Set the save dialog status to False by default.

Parameters:
  • parent (QWidget) – The parent widget for the mixin.

  • save_file_prefix (str) – The prefix for save file names.

copy_to_clipboard()

Copy the snapshot of the parent widget to the clipboard.

Returns:

None

static create_directory()

Create the directory for saving snapshots if it does not exist.

Returns:

The directory path for saving the snapshot.

Return type:

QDir

default_filename(suffix: str = '.png') str

Generate a default filename for saving snapshots.

Parameters:

suffix – The file extension to be appended to the filename. Default is ‘.png’.

Returns:

The default file path for saving the snapshot.

Return type:

str

eventFilter(source, event)

Filters events for the widget to handle context menu events.

Parameters:
  • source – The source of the event.

  • event – The event to be filtered.

Returns:

True if the event is a context menu event for the parent widget, False otherwise.

Return type:

bool

save_high_res_to_disk() None

Save a high-resolution snapshot of the parent widget to disk.

Opens a dialog to capture a high-resolution snapshot of the widget and saves it to the chosen file location. Resets the save dialog status after saving the snapshot.

Returns:

None

save_to_disk()

Save a snapshot of the parent widget to disk.

Prompts the user to choose a file location and format for saving the snapshot. If a file is selected, the snapshot of the widget is saved to the chosen location.

Returns:

None

show_context_menu(pos)

Display a context menu for the widget for capturing snapshots of the widget.

Parameters:

pos – The position where the context menu should be displayed.

Returns:

None

class midrc_react.gui.pyside6.grabbablewidget.SaveWidgetAsImageDialog(widget: QWidget, parent: QWidget | None = None)

Bases: QDialog

Dialog for saving a widget as an image with options to restore, cancel, and save the image with a specified ratio.

Variables:

widget – The widget to be saved as an image.

WINDOW_HEIGHT = 300
WINDOW_TITLE = 'Save High Resolution Image'
WINDOW_WIDTH = 400
__init__(widget: QWidget, parent: QWidget | None = None)

Initialize the SaveWidgetAsImageDialog with the specified widget and optional parent.

Parameters:
  • widget (QWidget) – The widget to be saved as an image.

  • parent (Optional[QWidget]) – The optional parent widget for the dialog.

cancel_save()

Restore the original widget and reject the save operation.

This method restores the original widget by removing the temporary widget and replaces it with the original. Then, it rejects the save operation.

closeEvent(event)

Handle the event when the dialog is closed.

Parameters:

event (QCloseEvent) – The close event triggered when the dialog is closed.

property image: QImage

Get the image generated from the widget.

Returns:

The image generated from the widget.

Return type:

QImage

save_image(_=None, *, ratio: int = 2)

Save the image of the widget with a specified ratio.

Creates an image of the widget with a given ratio, renders it using a QPainter, and then restores the original. Finally, accepts the save operation.

Parameters:
  • _ – Signals can send a parameter, so ignore it

  • ratio (int) – The ratio to scale the image.

midrc_react.gui.pyside6.jsdview module

This module contains the JsdWindow class, which represents the main window of the midrc_react application.

class midrc_react.gui.pyside6.jsdview.JsdChart(parent: ~PySide6.QtWidgets.QWidget | None = None, animation_options: int = <AnimationOption.AllAnimations: 3>)

Bases: QChart

Custom chart class for JSD data visualization.

__init__(parent: ~PySide6.QtWidgets.QWidget | None = None, animation_options: int = <AnimationOption.AllAnimations: 3>) None

Initialize the JsdChart with optional parent and animation options.

Parameters:
  • parent (Optional[QWidget]) – The parent widget.

  • animation_options (int) – Chart animation options.

class midrc_react.gui.pyside6.jsdview.JsdWindow(data_sources: Any)

Bases: QMainWindow, JsdViewBase

Main window of the MIDRC-REACT application.

Variables:
  • add_data_source (Signal) – Emitted when a new data source is added.

  • WINDOW_TITLE (str) – The window title.

  • DOCK_TITLES (dict) – Titles for various dock widgets.

DOCK_TITLES: Dict[str, str] = {'pie_chart_dock': 'Pie Charts - MIDRC-REACT Representativeness Exploration and Comparison Tool', 'spider_chart_dock': 'Distribution Charts - MIDRC-REACT Representativeness Exploration and Comparison Tool', 'table_dock': 'JSD Table - MIDRC-REACT Representativeness Exploration and Comparison Tool'}
WINDOW_TITLE: str = 'MIDRC-REACT Representativeness Exploration and Comparison Tool'
__init__(data_sources: Any) None

Initialize the JsdWindow with provided data sources and set up the GUI.

Parameters:

data_sources (Any) – Data sources used to initialize the data selection group box.

add_area_chart_view(area_chart: QChart) GrabbableChartView

Add an area chart view to the area chart widget.

Parameters:

area_chart (QChart) – The area chart to add.

Returns:

The view that was added.

Return type:

GrabbableChartView

add_data_source
add_spider_chart_view() GrabbableChartView

Add a spider chart view to the spider chart container.

Returns:

The spider chart view that was added.

Return type:

GrabbableChartView

adjust_number_of_files_to_compare() None

Open a dialog to adjust the number of files to compare and update the UI accordingly.

Returns:

None

create_main_layout() QVBoxLayout

Create and return the main layout for the application.

Returns:

The vertical box layout containing the data selection group box and timeline chart.

Return type:

QVBoxLayout

property create_menu_bar: QMenuBar

Create and return the main menu bar with File, Settings, and View menus.

Returns:

The created menu bar.

Return type:

QMenuBar

static create_pie_chart_dock_widget(layout: QLayout, title: str) QDockWidget

Create a dock widget for pie charts with a given layout and title.

Parameters:
  • layout (QLayout) – The layout containing pie chart widgets.

  • title (str) – The title of the dock widget.

Returns:

The created dock widget.

Return type:

QDockWidget

create_spider_chart_dock_widget(spider_chart_vbox: QSplitter, title: str) QDockWidget

Create a dock widget containing a spider chart and an area chart.

Parameters:
  • spider_chart_vbox (QSplitter) – The container for the spider chart.

  • title (str) – The title of the dock widget.

Returns:

The created dock widget.

Return type:

QDockWidget

static create_table_dock_widget(table_view: QTableView, title: str) QDockWidget

Create a dock widget that contains a table view.

Parameters:
  • table_view (QTableView) – The table view widget.

  • title (str) – The title of the dock widget.

Returns:

The created dock widget.

Return type:

QDockWidget

property dataselectiongroupbox: JsdDataSelectionGroupBox

Return the data selection group box widget.

Returns:

The data selection group box.

Return type:

JsdDataSelectionGroupBox

open_csv_tsv_file_dialog() None

Open a file dialog to select a CSV or TSV file and show its options dialog.

This function reads the header row to obtain available columns, then opens the CSVTSVOptionsDialog. It then validates and collects user selections and emits a data source dictionary.

open_excel_file_dialog() None

Open a file dialog to select an Excel file and show its options dialog.

Emits a data source dictionary via self.add_data_source and updates UI elements via self._dataselectiongroupbox.

open_yaml_input_dialog() None

Open a dialog to paste YAML content and add it as a data source.

The dialog loads previously saved YAML content (if available) and saves the current input upon acceptance.

populate_dock_widget_menu(dock_widget_menu: QMenu) None

Clear and repopulate the dock widget menu with toggle actions for each dock widget.

Parameters:

dock_widget_menu (QMenu) – The menu to populate.

reset_minimum_sizes() None

Reset the minimum sizes of the spider and pie chart dock widgets to allow free resizing.

Returns:

None

set_animation_options(enable_animations: bool) bool

Enable or disable chart animations.

Parameters:

enable_animations (bool) – True to enable animations, False to disable.

Returns:

True after setting the animation options.

Return type:

bool

set_default_widget_sizes() None

Set default sizes for main window and dock widgets for an optimal initial layout.

Returns:

None

update_area_chart(category: Dict[Any, Any]) bool

Update the area chart with new data from the provided sheets.

Parameters:

category (dict) – A dictionary where each key maps to a sheet containing chart data.

Returns:

True if area charts were updated.

Return type:

bool

update_jsd_timeline_plot(jsd_model: JSDTableModel) bool

Update the JSD timeline plot using the provided model.

Returns:

True if the timeline plot was updated successfully.

Return type:

bool

update_pie_chart_dock(sheet_dict: Dict[Any, Any]) None

Update the pie chart dock with the provided sheet data.

Parameters:

sheet_dict (dict) – A dictionary where each key maps to a set of sheets.

Returns:

None

update_spider_chart(spider_plot_values_dict: Dict[Any, Dict[str, float]]) bool

Update the spider chart with the provided plot values.

Parameters:

spider_plot_values_dict (dict) – Dictionary containing series values keyed by index pairs.

Returns:

True if chart updated; False if no data provided.

Return type:

bool

update_spider_chart_title(file1_data: str = 'File 1', file2_data: str = 'File 2') None

Update the title of the spider chart with the provided file names.

Parameters:
  • file1_data (str) – Data label for file 1.

  • file2_data (str) – Data label for file 2.

midrc_react.gui.pyside6.jsdview.clear_layout(layout: QLayout | None) bool

Recursively clear all widgets and sub-layouts from a given layout.

Parameters:

layout (Optional[QLayout]) – The layout to clear.

Returns:

True if layout cleared; False if layout was None.

Return type:

bool

midrc_react.gui.pyside6.launch_react module

This module contains the main function to launch MIDRC-REACT as a PySide6 application.

class midrc_react.gui.pyside6.launch_react.SplashScreen

Bases: QSplashScreen

This class is a subclass of QSplashScreen and represents a splash screen for a GUI application. It provides a static method _create_pixmap() to create a pixmap with a centered splash screen message. The __init__() method initializes the object and sets the pixmap.

BACKGROUND_COLOR = PySide6.QtGui.QColor.fromRgbF(1.000000, 1.000000, 1.000000, 1.000000)
FONT_FAMILY = 'Arial'
FONT_SIZE = 36
SPLASH_HEIGHT = 600
SPLASH_SCREEN_MESSAGE = 'MIDRC-REACT\n\nRepresentativeness Exploration\nand Comparison Tool\n\n\nLoading Excel files, please wait...'
SPLASH_WIDTH = 800
__init__() None

Initialize the object.

midrc_react.gui.pyside6.launch_react.launch_react()

Function: launch_react

This function launches the midrc_react application.

  • It checks if a QApplication instance already exists, and if not, creates one.

  • It then creates a SplashScreen object and displays it.

  • Next, it initializes a JSDConfig object and retrieves the data source list from the configuration.

  • It creates a JsdWindow object with the data source list and sets the JSDController with a JSDTableModel and the configuration.

  • Finally, it shows the JsdWindow, finishes the SplashScreen, and exits the application.

Returns:

None

Module contents