[GRASS-SVN] r45114 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 20 16:34:20 EST 2011


Author: martinl
Date: 2011-01-20 13:34:20 -0800 (Thu, 20 Jan 2011)
New Revision: 45114

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI/dialog: fix pre-defined value for widget gselect.Select


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-01-20 19:39:13 UTC (rev 45113)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-01-20 21:34:20 UTC (rev 45114)
@@ -136,7 +136,7 @@
     rgb2str[ r ] = s
 
 def color_resolve(color):
-    if len(color)>0 and color[0] in "0123456789":
+    if len(color) > 0 and color[0] in "0123456789":
         rgb = tuple(map(int, color.split(':')))
         label = color
     else:
@@ -1338,7 +1338,7 @@
                             txt2.SetName("TextCtrl")
                             style = wx.EXPAND | wx.BOTTOM | wx.LEFT
                         
-                        value = self._GetValue(p)
+                        value = self._getValue(p)
                         # parameter previously set
                         if value:
                             if txt2.GetName() ==  "SpinCtrl":
@@ -1357,7 +1357,7 @@
                         cb = wx.ComboBox(parent = which_panel, id = wx.ID_ANY, value = p.get('default',''),
                                          size = globalvar.DIALOG_COMBOBOX_SIZE,
                                          choices = valuelist, style = wx.CB_DROPDOWN)
-                        value = self._GetValue(p)
+                        value = self._getValue(p)
                         if value:
                             cb.SetValue(value) # parameter previously set
                         which_sizer.Add(item = cb, proportion = 0,
@@ -1378,7 +1378,7 @@
                         len(p.get('key_desc', [])) > 1:
                     txt3 = wx.TextCtrl(parent = which_panel, value = p.get('default',''))
                     
-                    value = self._GetValue(p)
+                    value = self._getValue(p)
                     if value:
                         # parameter previously set
                         txt3.SetValue(str(value))
@@ -1394,7 +1394,7 @@
                                            min = minValue, max = maxValue)
                         style = wx.BOTTOM | wx.LEFT | wx.RIGHT
                         
-                        value = self._GetValue(p)
+                        value = self._getValue(p)
                         if value:
                             txt3.SetValue(int(value)) # parameter previously set
                         
@@ -1404,7 +1404,7 @@
                                            validator = FloatValidator())
                         style = wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT
                         
-                        value = self._GetValue(p)
+                        value = self._getValue(p)
                         if value:
                             txt3.SetValue(str(value)) # parameter previously set
                     
@@ -1455,16 +1455,21 @@
                                                    size = globalvar.DIALOG_GSELECT_SIZE,
                                                    type = p.get('element', ''),
                                                    multiple = multiple, mapsets = mapsets)
+                        value = self._getValue(p)
+                        if value:
+                            selection.SetValue(value)
+                        
                         formatSelector = True
                         # A select.Select is a combobox with two children: a textctl and a popupwindow;
                         # we target the textctl here
-                        p['wxId'] = [selection.GetChildren()[0].GetId(), ]
-                        selection.GetChildren()[0].Bind(wx.EVT_TEXT, self.OnSetValue)
-                        
+                        textWin = selection.GetTextCtrl()
+                        p['wxId'] = [ textWin.GetId(), ]
+                        textWin.Bind(wx.EVT_TEXT, self.OnSetValue)
+                    
                     if p.get('prompt', '') ==  'vector':
                         selection.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
                         
-                        if formatSelector and p.get('age', '') ==  'old':
+                        if formatSelector and p.get('age', 'old') ==  'old':
                             # OGR supported (read-only)
                             self.hsizer = wx.BoxSizer(wx.HORIZONTAL)
                             
@@ -1669,7 +1674,7 @@
                                                       buttonText = _('Browse'),
                                                       startDirectory = os.getcwd(), fileMode = 0,
                                                       changeCallback = self.OnSetValue)
-                    value = self._GetValue(p)
+                    value = self._getValue(p)
                     if value:
                         fbb.SetValue(value) # parameter previously set
                     which_sizer.Add(item = fbb, proportion = 0,
@@ -1728,7 +1733,8 @@
 
             if p ==  first_param:
                 if p.has_key('wxId') and len(p['wxId']) > 0:
-                    self.FindWindowById(p['wxId'][0]).SetFocus()
+                    win = self.FindWindowById(p['wxId'][0])
+                    win.SetFocus()
         
         #
         # set widget relations for OnUpdateSelection
@@ -1851,7 +1857,7 @@
         
         self.Bind(EVT_DIALOG_UPDATE, self.OnUpdateDialog)
 
-    def _GetValue(self, p):
+    def _getValue(self, p):
         """!Get value or default value of given parameter
 
         @param p parameter directory



More information about the grass-commit mailing list