From e30d07d707f8b8cfb403aa3bd339c333d1188c97 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 28 Aug 2024 11:38:51 +0800 Subject: [PATCH] Fix pressing enter not working in conn menu --- pytec/pytec/gui/view/conn_menu.py | 5 +++-- pytec/tec_qt.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pytec/pytec/gui/view/conn_menu.py b/pytec/pytec/gui/view/conn_menu.py index 320d744..4a13af5 100644 --- a/pytec/pytec/gui/view/conn_menu.py +++ b/pytec/pytec/gui/view/conn_menu.py @@ -4,9 +4,10 @@ from pytec.gui.model.thermostat import ThermostatConnectionState class ConnMenu(QtWidgets.QMenu): - def __init__(self, thermostat): + def __init__(self, thermostat, connect_btn): super().__init__() self._thermostat = thermostat + self._connect_btn = connect_btn self._thermostat.connection_state_changed.connect( self.thermostat_state_change_handler ) @@ -20,7 +21,7 @@ class ConnMenu(QtWidgets.QMenu): self.host_set_line.setClearButtonEnabled(True) def connect_on_enter_press(): - self.connect_btn.click() + self._connect_btn.click() self.hide() self.host_set_line.returnPressed.connect(connect_on_enter_press) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index ff38ba9..1de0af2 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -112,7 +112,7 @@ class MainWindow(QtWidgets.QMainWindow): self.plot_options_menu = PlotOptionsMenu(self.channel_graphs) self.plot_settings.setMenu(self.plot_options_menu) - self.conn_menu = ConnMenu(self.thermostat) + self.conn_menu = ConnMenu(self.thermostat, self.connect_btn) self.connect_btn.setMenu(self.conn_menu) self.thermostat_ctrl_menu = ThermostatCtrlMenu(