From 463ee4105c638efcda924db2a4c2a97b61cd7082 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 19 Jul 2023 11:38:04 +0800 Subject: [PATCH] Context menu by QToolButton --- pytec/tec_qt.py | 3 +++ pytec/tec_qt.ui | 10 ++++++++++ pytec/ui_tec_qt.py | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 8c72bed..6dff78f 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -73,6 +73,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.setupUi(self) + menu = QtWidgets.QMenu(self) + self.thermostat_settings.setMenu(menu) + self.fan_power_slider.valueChanged.connect(self.fan_set) self.fan_auto_box.stateChanged.connect(self.fan_auto_set) diff --git a/pytec/tec_qt.ui b/pytec/tec_qt.ui index 551ef66..8430c9e 100644 --- a/pytec/tec_qt.ui +++ b/pytec/tec_qt.ui @@ -294,6 +294,16 @@ + + + + + + + QToolButton::InstantPopup + + + diff --git a/pytec/ui_tec_qt.py b/pytec/ui_tec_qt.py index 8144ebd..2576458 100644 --- a/pytec/ui_tec_qt.py +++ b/pytec/ui_tec_qt.py @@ -136,6 +136,11 @@ class Ui_MainWindow(object): self.status_lbl.setBaseSize(QtCore.QSize(120, 50)) self.status_lbl.setObjectName("status_lbl") self.settings_layout.addWidget(self.status_lbl) + self.thermostat_settings = QtWidgets.QToolButton(parent=self.bottom_settings_group) + self.thermostat_settings.setText("⚙") + self.thermostat_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup) + self.thermostat_settings.setObjectName("thermostat_settings") + self.settings_layout.addWidget(self.thermostat_settings) self.line_0 = QtWidgets.QFrame(parent=self.bottom_settings_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) sizePolicy.setHorizontalStretch(0)