IDE: Fix status bar update when conection lost
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 09 Oct 2023 21:27:17 +0200
changeset 3865 c1754cd1c298
parent 3864 3e434edfbfdf
child 3866 eb107a25556b
IDE: Fix status bar update when conection lost
ProjectController.py
--- a/ProjectController.py	Mon Oct 09 16:42:59 2023 +0200
+++ b/ProjectController.py	Mon Oct 09 21:27:17 2023 +0200
@@ -1509,15 +1509,11 @@
             if self.AppFrame is not None:
                 updated = True
                 self.AppFrame.RefreshStatusToolBar()
-                if status == PlcStatus.Disconnected:
-                    self.AppFrame.ConnectionStatusBar.SetStatusText(
-                        _(status), 1)
-                    self.AppFrame.ConnectionStatusBar.SetStatusText('', 2)
-                else:
-                    self.AppFrame.ConnectionStatusBar.SetStatusText(
-                        _("Connected to URI: %s") % self.BeremizRoot.getURI_location().strip(), 1)
-                    self.AppFrame.ConnectionStatusBar.SetStatusText(
-                        _(status), 2)
+                texts = [_(PlcStatus.Disconnected), ''] \
+                        if status == PlcStatus.Disconnected or self._connector is None else \
+                        [_("Connected to URI: %s") % self.BeremizRoot.getURI_location().strip(), _(status)]
+                for i,txt in enumerate(texts):
+                    self.AppFrame.ConnectionStatusBar.SetStatusText(txt, i+1)
         return updated
 
     def ShowPLCProgress(self, status="", progress=0):