controls/LocationCellEditor.py
changeset 714 131ea7f237b9
parent 657 b286a16162fc
child 723 5df934c273e1
--- a/controls/LocationCellEditor.py	Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/LocationCellEditor.py	Mon Jun 25 20:03:53 2012 +0200
@@ -28,48 +28,31 @@
 
 class LocationCellControl(wx.PyControl):
     
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddWindow(self.Location, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.BrowseButton, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_MainSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_sizers(self):
-        self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
-        
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_MainSizer_Growables(self.MainSizer)
-        
-        self.SetSizer(self.MainSizer)
-    
-    def _init_ctrls(self, prnt):
-        wx.Control.__init__(self, id=-1, 
-              name='LocationCellControl', parent=prnt,  
-              size=wx.DefaultSize, style=0)
-        
-        # create location text control
-        self.Location = wx.TextCtrl(id=-1, name='Location', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER)
-        self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar)
-        
-        # create browse button
-        self.BrowseButton = wx.Button(id=-1, label='...', 
-              name='BrowseButton', parent=self, pos=wx.Point(0, 0), 
-              size=wx.Size(30, 0), style=0)
-        self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick)
-
-        self.Bind(wx.EVT_SIZE, self.OnSize)
-        
-        self._init_sizers()
-
     '''
     Custom cell editor control with a text box and a button that launches
     the BrowseLocationsDialog.
     '''
     def __init__(self, parent):
-        self._init_ctrls(parent)
+        wx.Control.__init__(self, parent)
+        
+        main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
+        main_sizer.AddGrowableCol(0)
+        main_sizer.AddGrowableRow(0)
+        
+        # create location text control
+        self.Location = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER)
+        self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar)
+        main_sizer.AddWindow(self.Location, flag=wx.GROW)
+        
+        # create browse button
+        self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, 0))
+        self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick)
+        main_sizer.AddWindow(self.BrowseButton, flag=wx.GROW)
+        
+        self.Bind(wx.EVT_SIZE, self.OnSize)
+        
+        self.SetSizer(main_sizer)
+
         self.Locations = None
         self.VarType = None
         self.Default = False
@@ -123,10 +106,11 @@
     '''
     Grid cell editor that uses LocationCellControl to display a browse button.
     '''
-    def __init__(self, table, controler):
+    def __init__(self, table, controller):
         wx.grid.PyGridCellEditor.__init__(self)
+        
         self.Table = table
-        self.Controler = controler
+        self.Controller = controller
 
     def __del__(self):
         self.CellControl = None
@@ -139,10 +123,10 @@
 
     def BeginEdit(self, row, col, grid):
         self.CellControl.Enable()
-        self.CellControl.SetLocations(self.Controler.GetVariableLocationTree())
+        self.CellControl.SetLocations(self.Controller.GetVariableLocationTree())
         self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location'))
         if isinstance(self.CellControl, LocationCellControl):
-            self.CellControl.SetVarType(self.Controler.GetBaseType(self.Table.GetValueByName(row, 'Type')))
+            self.CellControl.SetVarType(self.Controller.GetBaseType(self.Table.GetValueByName(row, 'Type')))
         self.CellControl.SetFocus()
 
     def EndEdit(self, row, col, grid):
@@ -160,5 +144,5 @@
                                         wx.SIZE_ALLOW_MINUS_ONE)
 
     def Clone(self):
-        return LocationCellEditor(self.Table, self.Controler)
+        return LocationCellEditor(self.Table, self.Controller)