Skip to content

hardware_sets_view

frog.gui.hardware_set.hardware_sets_view ¤

Provides a panel for choosing between hardware sets and (dis)connecting.

Attributes¤

Classes¤

HardwareSetNameDialog(parent) ¤

Bases: QDialog

A dialog for choosing a name for a new hardware set.

Create a new HardwareSetNameDialog.

Source code in src/frog/gui/hardware_set/hardware_sets_view.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def __init__(self, parent: QWidget) -> None:
    """Create a new HardwareSetNameDialog."""
    super().__init__(parent)
    self.setWindowTitle("Device configuration name")

    layout = QGridLayout()
    layout.addWidget(QLabel("Name for device configuration:"), 0, 0)

    self._name_widget = QLineEdit()
    self._name_widget.setMinimumSize(200, self._name_widget.minimumHeight())
    layout.addWidget(self._name_widget, 0, 1)

    btn_box = QDialogButtonBox(
        QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
    )
    btn_box.accepted.connect(self.accept)
    btn_box.rejected.connect(self.reject)
    layout.addWidget(btn_box, 1, 0, 1, 2)

    self.setLayout(layout)
Functions¤
show_and_get_name() ¤

Show the dialog and try to get the name chosen.

If the user closes the dialog, None is returned.

Source code in src/frog/gui/hardware_set/hardware_sets_view.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def show_and_get_name(self) -> str | None:
    """Show the dialog and try to get the name chosen.

    If the user closes the dialog, None is returned.
    """
    while True:
        accepted = self.exec()
        if not accepted:
            # User cancelled
            return None

        name = self._name_widget.text().strip()
        if name:
            # Valid name chosen
            return name

        msgbox = QMessageBox(
            QMessageBox.Icon.Critical,
            "No name provided",
            "You must provide a name for the device configuration",
        )
        msgbox.exec()

HardwareSetsControl(device_manager=None) ¤

Bases: QGroupBox

A panel for choosing between hardware sets and (dis)connecting.

Create a new HardwareSetsControl.

Source code in src/frog/gui/hardware_set/hardware_sets_view.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
def __init__(
    self,
    device_manager: ActiveDeviceManager | None = None,
) -> None:
    """Create a new HardwareSetsControl."""
    super().__init__("Devices")

    if not device_manager:
        device_manager = ActiveDeviceManager()
    device_manager.device_started_open.connect(self._on_device_open_start)
    device_manager.device_opened.connect(self._on_device_open_end)
    device_manager.device_closed.connect(self._on_device_closed)
    self._device_manager = device_manager

    self._combo = HardwareSetsComboBox()
    """A combo box for the different hardware sets."""
    self._combo.setSizePolicy(
        QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum
    )
    if last_selected := _get_last_selected_hardware_set():
        self._combo.current_hardware_set = last_selected

    self._connect_btn = QPushButton("Connect")
    self._connect_btn.setSizePolicy(
        QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum
    )
    self._connect_btn.pressed.connect(self._on_connect_btn_pressed)
    self._disconnect_btn = QPushButton("Disconnect all")
    self._disconnect_btn.setSizePolicy(
        QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum
    )
    self._disconnect_btn.pressed.connect(self._on_disconnect_btn_pressed)

    self._remove_hw_set_btn = QPushButton("Remove")
    self._remove_hw_set_btn.pressed.connect(self._remove_current_hardware_set)

    manage_devices_btn = QPushButton("Manage devices")
    manage_devices_btn.pressed.connect(self._show_manage_devices_dialog)
    self._manage_devices_dialog: ManageDevicesDialog

    row1 = QHBoxLayout()
    row1.addWidget(self._combo)
    row1.addWidget(self._connect_btn)
    row1.addWidget(self._disconnect_btn)
    row2 = QHBoxLayout()
    row2.addWidget(self._remove_hw_set_btn)
    row2.addWidget(manage_devices_btn)

    layout = QVBoxLayout()
    layout.addLayout(row1)
    layout.addLayout(row2)
    self.setLayout(layout)

    self._update_control_state()

    self._combo.currentIndexChanged.connect(self._update_control_state)
Functions¤

ManageDevicesDialog(device_manager) ¤

Bases: QDialog

A dialog for manually opening, closing and configuring devices.

Create a new ManageDevicesDialog.

Source code in src/frog/gui/hardware_set/hardware_sets_view.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def __init__(self, device_manager: ActiveDeviceManager) -> None:
    """Create a new ManageDevicesDialog."""
    super().__init__()
    self.setWindowTitle("Manage devices")
    self.setModal(True)

    device_manager.device_opened.connect(self._update_save_button_state)
    device_manager.device_closed.connect(self._update_save_button_state)
    self._device_manager = device_manager

    layout = QVBoxLayout()
    layout.addWidget(DeviceControl(device_manager))

    self._save_btn = QPushButton("Save device configuration")
    self._save_btn.setIcon(
        self.style().standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton)
    )
    self._save_btn.clicked.connect(self._save_hardware_set)

    buttonbox = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
    buttonbox.addButton(self._save_btn, QDialogButtonBox.ButtonRole.ActionRole)
    buttonbox.accepted.connect(self.accept)
    layout.addWidget(buttonbox)

    self.setLayout(layout)

    self._update_save_button_state()
Functions¤

Functions¤