From da70430c35493758315cefa40a66f6ba7210c76f Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 20 Jun 2024 15:25:04 +0800 Subject: [PATCH] Make connection loss handling more elegant Show an info box on connection lost informing the user that the Thermostat was forcefully disconnected. --- pytec/tec_qt.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index f6bd77a..79068fd 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -64,7 +64,15 @@ class MainWindow(QtWidgets.QMainWindow): self.info_box = InfoBox() self.client = WrappedClient(self) - self.client.connection_error.connect(self.bail) + + def handle_connection_error(): + self.info_box.display_info_box( + "Connection Error", "Thermostat connection lost. Is it unplugged?" + ) + + self.bail() + + self.client.connection_error.connect(handle_connection_error) self.thermostat = Thermostat( self, self.client, self.report_refresh_spin.value()