From fda4cc9bfb80760453ba9c02f222523a3b447421 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 bfd39b0..6ccad8c 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()