Fix bugs with Viewer objects dialogs
authorLaurent Bessard
Sun, 19 Aug 2012 16:02:12 +0200
changeset 741 330f578e228d
parent 740 b40ef1010140
child 742 75096d6c271c
Fix bugs with Viewer objects dialogs
PLCOpenEditor.py
Viewer.py
controls/LibraryPanel.py
dialogs/FBDBlockDialog.py
dialogs/FBDVariableDialog.py
--- a/PLCOpenEditor.py	Mon Aug 13 10:41:27 2012 +0200
+++ b/PLCOpenEditor.py	Sun Aug 19 16:02:12 2012 +0200
@@ -1316,12 +1316,12 @@
                 MenuToolBar.EnableTool(wx.ID_CUT, True)
                 self.EditMenu.Enable(wx.ID_COPY, True)
                 MenuToolBar.EnableTool(wx.ID_COPY, True)
-                if self.GetCopyBuffer() is not None:
-                    self.EditMenu.Enable(wx.ID_PASTE, True)
-                    MenuToolBar.EnableTool(wx.ID_PASTE, True)
-                else:
-                    self.EditMenu.Enable(wx.ID_PASTE, False)
-                    MenuToolBar.EnableTool(wx.ID_PASTE, False)
+#                if self.GetCopyBuffer() is not None:
+#                    self.EditMenu.Enable(wx.ID_PASTE, True)
+#                    MenuToolBar.EnableTool(wx.ID_PASTE, True)
+#                else:
+#                    self.EditMenu.Enable(wx.ID_PASTE, False)
+#                    MenuToolBar.EnableTool(wx.ID_PASTE, False)
                 self.EditMenu.Enable(wx.ID_SELECTALL, True)
             else:
                 self.EditMenu.Enable(wx.ID_CUT, False)
--- a/Viewer.py	Mon Aug 13 10:41:27 2012 +0200
+++ b/Viewer.py	Sun Aug 19 16:02:12 2012 +0200
@@ -927,7 +927,7 @@
         if self.ParentWindow:
             self.ParentWindow.RefreshTitle()
             self.ParentWindow.RefreshFileMenu()
-            self.ParentWindow.RefreshEditMenu()
+            wx.CallAfter(self.ParentWindow.RefreshEditMenu)
     
     def StartBuffering(self):
         if not self.Buffering:
--- a/controls/LibraryPanel.py	Mon Aug 13 10:41:27 2012 +0200
+++ b/controls/LibraryPanel.py	Sun Aug 19 16:02:12 2012 +0200
@@ -39,7 +39,7 @@
     def __init__(self, parent, enable_drag=False):
         wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
         
-        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
+        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
         main_sizer.AddGrowableCol(0)
         main_sizer.AddGrowableRow(1)
         
@@ -52,7 +52,12 @@
         search_textctrl.Bind(wx.EVT_CHAR, self.OnKeyDown)
         main_sizer.AddWindow(self.SearchCtrl, flag=wx.GROW)
         
-        self.Tree = wx.TreeCtrl(self, 
+        splitter_window = wx.SplitterWindow(self)
+        splitter_window.SetSashGravity(1.0)
+        main_sizer.AddWindow(splitter_window, flag=wx.GROW)
+        
+        self.Tree = wx.TreeCtrl(splitter_window,
+              size=wx.Size(0, 0),  
               style=wx.TR_HAS_BUTTONS|
                     wx.TR_SINGLE|
                     wx.SUNKEN_BORDER|
@@ -62,11 +67,11 @@
         self.Tree.Bind(wx.EVT_CHAR, self.OnKeyDown)
         if enable_drag:
             self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTreeBeginDrag, self.Tree)
-        main_sizer.AddWindow(self.Tree, flag=wx.GROW)
-        
-        self.Comment = wx.TextCtrl(self, size=wx.Size(0, 80), 
+        
+        self.Comment = wx.TextCtrl(splitter_window, size=wx.Size(0, 80), 
               style=wx.TE_READONLY|wx.TE_MULTILINE)
-        main_sizer.AddWindow(self.Comment, flag=wx.GROW)
+        
+        splitter_window.SplitHorizontally(self.Tree, self.Comment, -80)
         
         self.SetSizer(main_sizer)
             
--- a/dialogs/FBDBlockDialog.py	Mon Aug 13 10:41:27 2012 +0200
+++ b/dialogs/FBDBlockDialog.py	Sun Aug 19 16:02:12 2012 +0200
@@ -114,7 +114,7 @@
         right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
         
         button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+        #self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
         main_sizer.AddSizer(button_sizer, border=20, 
               flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
         
@@ -134,6 +134,9 @@
         
         self.LibraryPanel.SetFocus()
     
+    def __del__(self):
+        self.Controller = None
+    
     def SetBlockList(self, blocklist):
         self.LibraryPanel.SetBlockList(blocklist)
     
--- a/dialogs/FBDVariableDialog.py	Mon Aug 13 10:41:27 2012 +0200
+++ b/dialogs/FBDVariableDialog.py	Sun Aug 19 16:02:12 2012 +0200
@@ -89,7 +89,8 @@
         name_label = wx.StaticText(self, label=_('Name:'))
         right_gridsizer.AddWindow(name_label, flag=wx.GROW)
         
-        self.VariableName = wx.ListBox(self, style=wx.LB_SINGLE|wx.LB_SORT)
+        self.VariableName = wx.ListBox(self, size=wx.Size(0, 0), 
+              style=wx.LB_SINGLE|wx.LB_SORT)
         self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, self.VariableName)
         right_gridsizer.AddWindow(self.VariableName, flag=wx.GROW)