From fae0c4141d897da009d7316462678e9c3005d0c9 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 e96b928..dfee892 100644 --- 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()