Added support for StatusBar
authorLaurent Bessard
Tue, 26 Mar 2013 00:35:52 +0100
changeset 1000 d19af9341d28
parent 999 cbab4c1635bd
child 1001 3f966bbb3fba
Added support for StatusBar
Beremiz.py
ProjectController.py
--- a/Beremiz.py	Tue Mar 26 00:03:57 2013 +0100
+++ b/Beremiz.py	Tue Mar 26 00:35:52 2013 +0100
@@ -364,6 +364,15 @@
               kind=wx.ITEM_NORMAL, text=_(u'About'))
         self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
     
+    def _init_coll_ConnectionStatusBar_Fields(self, parent):
+        parent.SetFieldsCount(3)
+
+        parent.SetStatusText(number=0, text='')
+        parent.SetStatusText(number=1, text='')
+        parent.SetStatusText(number=2, text='')
+
+        parent.SetStatusWidths([-1, 300, 200])
+    
     def _init_ctrls(self, prnt):
         IDEFrame._init_ctrls(self, prnt)
         
@@ -429,6 +438,10 @@
         
         self.AUIManager.Update()
         
+        self.ConnectionStatusBar = wx.StatusBar(self, style=wx.ST_SIZEGRIP)
+        self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar)
+        self.SetStatusBar(self.ConnectionStatusBar)
+        
     def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True):
         IDEFrame.__init__(self, parent, debug)
         self.Log = LogPseudoFile(self.LogConsole,self.SelectTab)
@@ -801,6 +814,10 @@
     def GetConfigEntry(self, entry_name, default):
         return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default))))
     
+    def ResetConnectionStatusBar(self):
+        for field in xrange(self.ConnectionStatusBar.GetFieldsCount()):
+            self.ConnectionStatusBar.SetStatusText('', field)
+    
     def ResetView(self):
         IDEFrame.ResetView(self)
         self.ConfNodeInfos = {}
@@ -810,6 +827,7 @@
         self.Log.flush()
         if self.EnableDebug:
             self.DebugVariablePanel.SetDataProducer(None)
+            self.ResetConnectionStatusBar()
     
     def RefreshConfigRecentProjects(self, projectpath):
         try:
--- a/ProjectController.py	Tue Mar 26 00:03:57 2013 +0100
+++ b/ProjectController.py	Tue Mar 26 00:35:52 2013 +0100
@@ -313,7 +313,9 @@
 
         if os.path.isfile(self._getIECrawcodepath()):
             self.ShowMethod("_showIECcode", True)
-
+        
+        self.UpdateMethodsFromPLCStatus()
+        
         return None
     
     def RecursiveConfNodeInfos(self, confnode):
@@ -1109,13 +1111,17 @@
                                       ("_Disconnect", False)],
                    }.get(status,[]):
                 self.ShowMethod(*args)
-            {"Broken": self.logger.write_error,
-             None: lambda x: None}.get(
-                status, self.logger.write)(_("PLC state is \"%s\"\n")%_(status))
             self.previous_plcstate = status
             if self.AppFrame is not None:
                 self.AppFrame.RefreshStatusToolBar()
-    
+                if status == "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)
+                
     def PullPLCStatusProc(self, event):
         self.UpdateMethodsFromPLCStatus()