Skip to content

App

rionid.gui.app

MainWindow

Bases: QWidget

The main application window for RionID.

This class acts as the central container, arranging the input parameters panel (left) and the visualization plot (right) using a QSplitter. It handles the signal connections between the input logic and the plotting display.

Attributes:

Name Type Description
visualization_widget CreatePyGUI

The right-hand panel containing the PyQtGraph plot.

rion_input RionID_GUI

The left-hand panel containing input fields and control buttons.

Source code in src/rionid/gui/app.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class MainWindow(QWidget):
    """
    The main application window for RionID.

    This class acts as the central container, arranging the input parameters panel
    (left) and the visualization plot (right) using a QSplitter. It handles the
    signal connections between the input logic and the plotting display.

    Attributes
    ----------
    visualization_widget : CreatePyGUI
        The right-hand panel containing the PyQtGraph plot.
    rion_input : RionID_GUI
        The left-hand panel containing input fields and control buttons.
    """

    def __init__(self):
        """
        Initializes the main window, sets geometry, and connects signals.
        """
        super().__init__()
        self.setWindowTitle("RionID")

        screen = QApplication.primaryScreen()
        screen_geom = screen.availableGeometry()
        width = int(screen_geom.width() * 0.8)
        height = int(screen_geom.height() * 0.8)

        # Center the window
        x = (screen_geom.width() - width) // 2
        y = (screen_geom.height() - height) // 2
        self.setGeometry(x, y, width, height)

        # Create a QSplitter to hold both the input and the visualization
        splitter = QSplitter(Qt.Horizontal)

        # Create the visualization before the input panel.
        self.visualization_widget = CreatePyGUI()

        # Create the input widget and connect it to the visualization.
        self.rion_input = RionID_GUI(plot_widget=self.visualization_widget)

        # Add widgets to the splitter
        splitter.addWidget(self.rion_input)
        splitter.addWidget(self.visualization_widget)

        # Set initial size ratios (1 part input, 2 parts plot)
        splitter.setStretchFactor(0, 1)
        splitter.setStretchFactor(1, 2)

        # Create the main layout
        layout = QVBoxLayout()
        layout.addWidget(splitter)
        self.setLayout(layout)

        # --- Signal Connections ---

        # Update plot when a full simulation run finishes
        self.rion_input.visualization_signal.connect(self.update_visualization)

    def update_visualization(self, data):
        """
        Updates the visualization widget with new experimental and simulated data.

        This slot is triggered when a full simulation run is completed. It replaces
        all existing data on the plot (experimental and simulated).

        Parameters
        ----------
        data : ImportData
            The data object containing experimental spectrum arrays and
            simulated ion frequency dictionaries.
        """
        self.visualization_widget.updateData(data)

__init__()

Initializes the main window, sets geometry, and connects signals.

Source code in src/rionid/gui/app.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def __init__(self):
    """
    Initializes the main window, sets geometry, and connects signals.
    """
    super().__init__()
    self.setWindowTitle("RionID")

    screen = QApplication.primaryScreen()
    screen_geom = screen.availableGeometry()
    width = int(screen_geom.width() * 0.8)
    height = int(screen_geom.height() * 0.8)

    # Center the window
    x = (screen_geom.width() - width) // 2
    y = (screen_geom.height() - height) // 2
    self.setGeometry(x, y, width, height)

    # Create a QSplitter to hold both the input and the visualization
    splitter = QSplitter(Qt.Horizontal)

    # Create the visualization before the input panel.
    self.visualization_widget = CreatePyGUI()

    # Create the input widget and connect it to the visualization.
    self.rion_input = RionID_GUI(plot_widget=self.visualization_widget)

    # Add widgets to the splitter
    splitter.addWidget(self.rion_input)
    splitter.addWidget(self.visualization_widget)

    # Set initial size ratios (1 part input, 2 parts plot)
    splitter.setStretchFactor(0, 1)
    splitter.setStretchFactor(1, 2)

    # Create the main layout
    layout = QVBoxLayout()
    layout.addWidget(splitter)
    self.setLayout(layout)

    # --- Signal Connections ---

    # Update plot when a full simulation run finishes
    self.rion_input.visualization_signal.connect(self.update_visualization)

update_visualization(data)

Updates the visualization widget with new experimental and simulated data.

This slot is triggered when a full simulation run is completed. It replaces all existing data on the plot (experimental and simulated).

Parameters:

Name Type Description Default
data ImportData

The data object containing experimental spectrum arrays and simulated ion frequency dictionaries.

required
Source code in src/rionid/gui/app.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def update_visualization(self, data):
    """
    Updates the visualization widget with new experimental and simulated data.

    This slot is triggered when a full simulation run is completed. It replaces
    all existing data on the plot (experimental and simulated).

    Parameters
    ----------
    data : ImportData
        The data object containing experimental spectrum arrays and
        simulated ion frequency dictionaries.
    """
    self.visualization_widget.updateData(data)

main()

The main entry point for the RionID GUI application.

Initializes the QApplication, creates the MainWindow, and starts the Qt event loop.

Source code in src/rionid/gui/app.py
89
90
91
92
93
94
95
96
97
98
99
def main():
    """
    The main entry point for the RionID GUI application.

    Initializes the QApplication, creates the MainWindow, and starts the
    Qt event loop.
    """
    app = QApplication(sys.argv)
    main_window = MainWindow()
    main_window.show()
    sys.exit(app.exec_())