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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 5 07:45:36 EST 2008


Author: martinl
Date: 2008-03-05 07:45:36 -0500 (Wed, 05 Mar 2008)
New Revision: 30478

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI (menuform) use wx.SpinCtrl for numeric types
fix setting default value(s)


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-03-05 11:22:56 UTC (rev 30477)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-03-05 12:45:36 UTC (rev 30478)
@@ -936,7 +936,7 @@
                     else:
                         hSizer=wx.StaticBoxSizer ( box=txt, orient=wx.HORIZONTAL )
                     isDefault = {}
-                    for defval in p.get('value','').split(','):
+                    for defval in p.get('default','').split(','):
                         isDefault[ defval ] = 'yes'
                         # for multi checkboxes, this is an array of all wx IDs
                         # for each individual checkbox
@@ -1004,15 +1004,24 @@
                 which_sizer.Add(item=txt, proportion=0,
                                 flag=wx.RIGHT | wx.LEFT | wx.TOP | wx.EXPAND, border=5)
 
-                txt3 = wx.TextCtrl(parent=which_panel, value = p.get('default',''),
-                                   size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
-
+                if p.get('type','string') == 'string':
+                    txt3 = wx.TextCtrl(parent=which_panel, value = p.get('default',''),
+                                       size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
+                    txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
+                else:
+                    minValue = -1e9
+                    maxValue = 1e9
+                    txt3 = wx.SpinCtrl(parent=which_panel, value=p.get('default',''),
+                                       size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT),
+                                       min=minValue, max=maxValue)
+                    txt3.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
+                    txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
+                    
                 if p.get('value','') != '':
                     txt3.SetValue(p['value']) # parameter previously set
 
                 which_sizer.Add(item=txt3, proportion=0, flag=wx.BOTTOM | wx.LEFT, border=5)
                 p['wxId'] = txt3.GetId()
-                txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
 
             if p.get('type','string') == 'string' and p.get('gisprompt',False) == True:
                 txt = wx.StaticText(parent=which_panel, label = title + ':')



More information about the grass-commit mailing list