diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 6dff78f..ab694c1 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -73,8 +73,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.setupUi(self) - menu = QtWidgets.QMenu(self) - self.thermostat_settings.setMenu(menu) + self._set_up_context_menu() self.fan_power_slider.valueChanged.connect(self.fan_set) self.fan_auto_box.stateChanged.connect(self.fan_auto_set) @@ -95,6 +94,22 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.port_set_spin.setValue(int(args.PORT)) self.connect_btn.click() + def _set_up_context_menu(self): + self.menu = QtWidgets.QMenu() + self.menu.setTitle('Thermostat settings') + + fan = QtWidgets.QWidgetAction(self.menu) + fan.setDefaultWidget(self.fan_group) + self.menu.addAction(fan) + self.menu.fan = fan + + port = QtWidgets.QWidgetAction(self.menu) + port.setDefaultWidget(self.port_set_spin) + self.menu.addAction(port) + self.menu.port = port + + self.thermostat_settings.setMenu(self.menu) + async def _on_connection_changed(self, result): self.graph_group.setEnabled(result) self.fan_group.setEnabled(result)