Adding support for refresh block list where beremiz loose focus
authorlbessard
Fri, 05 Oct 2007 17:55:49 +0200
changeset 62 ddf0cdd71558
parent 61 a20fb174f46e
child 63 bdb196c40619
Adding support for refresh block list where beremiz loose focus
(fixing bug on grid editors in plcopeneditor)
Beremiz.py
plugger.py
--- a/Beremiz.py	Fri Oct 05 17:51:55 2007 +0200
+++ b/Beremiz.py	Fri Oct 05 17:55:49 2007 +0200
@@ -260,6 +260,7 @@
         self._init_utils()
         self.SetClientSize(wx.Size(1000, 600))
         self.SetMenuBar(self.menuBar1)
+        self.Bind(wx.EVT_ACTIVATE, self.OnFrameActivated)
         
         self.MainSplitter = wx.SplitterWindow(id=ID_BEREMIZMAINSPLITTER,
               name='MainSplitter', parent=self, point=wx.Point(0, 0),
@@ -332,7 +333,11 @@
         self.RefreshPluginParams()
         self.RefreshButtons()
         self.RefreshMainMenu()
-        
+    
+    def OnFrameActivated(self, event):
+        if not event.GetActive():
+            self.PluginRoot.RefreshPluginsBlockLists()
+    
     def RefreshButtons(self):
         if self.PluginRoot.HasProjectOpened():
             self.PluginChilds.Enable(True)
@@ -493,6 +498,7 @@
                         button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, method), id=id)
                         boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT)
             self.ParamsPanelMainSizer.Layout()
+            self.ParamsPanel.SetClientSize(self.ParamsPanel.GetClientSize())
             
             # Refresh PluginChilds
             self.PluginChilds.Clear()
@@ -575,10 +581,7 @@
                 
     def RefreshSizerElement(self, sizer, elements, path, clean = True):
         if clean:
-            if wx.VERSION >= (2, 7, 0):
-                sizer.Clear(True)
-            else:
-                self.ClearSizer(sizer)
+            sizer.Clear(True)
         first = True
         for element_infos in elements:
             if path:
--- a/plugger.py	Fri Oct 05 17:51:55 2007 +0200
+++ b/plugger.py	Fri Oct 05 17:55:49 2007 +0200
@@ -665,10 +665,13 @@
     
     # Update PLCOpenEditor Plugin Block types from loaded plugins
     def RefreshPluginsBlockLists(self):
-        ClearPluginTypes()
-        AddPluginBlockList(self.BlockTypesFactory())
-        for child in self.IterChilds():
-            AddPluginBlockList(child.BlockTypesFactory())
+        if getattr(self, "PluggedChilds", None) is not None:
+            ClearPluginTypes()
+            AddPluginBlockList(self.BlockTypesFactory())
+            for child in self.IterChilds():
+                AddPluginBlockList(child.BlockTypesFactory())
+        if self.PLCEditor is not None:
+            self.PLCEditor.RefreshEditor()
     
     def PlugPath(self, PlugName=None):
         return self.ProjectPath
@@ -871,7 +874,7 @@
         new_dialog.Show()
 
     def _EditPLC(self, logger):
-        if not self.PLCEditor:
+        if self.PLCEditor is None:
             self.RefreshPluginsBlockLists()
             def _onclose():
                 self.PLCEditor = None