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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 3 07:15:56 EDT 2010


Author: martinl
Date: 2010-04-03 07:15:55 -0400 (Sat, 03 Apr 2010)
New Revision: 41685

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI:use floatspin


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-03 09:29:09 UTC (rev 41684)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-03 11:15:55 UTC (rev 41685)
@@ -75,6 +75,11 @@
 from wx.lib.newevent import NewEvent
 
 try:
+    import wx.lib.agw.floatspin as FS
+except ImportError:
+    FS = None
+
+try:
     import xml.etree.ElementTree as etree
 except ImportError:
     import elementtree.ElementTree as etree # Python <= 2.4
@@ -1252,7 +1257,7 @@
                         title_txt.SetLabel("%s. %s %s" % (title, _('Valid range'),
                                                           str(valuelist[0]) + ':'))
                         
-                        if p.get('type','') == 'integer' and \
+                        if p.get('type', '') == 'integer' and \
                                 p.get('multiple','no') == 'no':
 
                             # for multiple integers use textctrl instead of spinsctrl
@@ -1304,7 +1309,7 @@
 
                 title_txt.SetLabel(title + ':' )
                 if p.get('multiple','yes') == 'yes' or \
-                        p.get('type', 'string') in ('string', 'float') or \
+                        p.get('type', 'string') == 'string' or \
                         len(p.get('key_desc', [])) > 1:
                     txt3 = wx.TextCtrl(parent=which_panel, value = p.get('default',''))
                     
@@ -1316,15 +1321,35 @@
                 else:
                     minValue = -1e9
                     maxValue = 1e9
-                    txt3 = wx.SpinCtrl(parent=which_panel, value=p.get('default',''),
-                                       size=globalvar.DIALOG_SPIN_SIZE,
-                                       min=minValue, max=maxValue)
-                    if p.get('value','') != '':
-                        txt3.SetValue(int(p['value'])) # parameter previously set
-
-                    txt3.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
-                    txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
-                    style = wx.BOTTOM | wx.LEFT | wx.RIGHT
+                    if p.get('type', '') == 'integer':
+                        txt3 = wx.SpinCtrl(parent=which_panel, value=p.get('default',''),
+                                           size=globalvar.DIALOG_SPIN_SIZE,
+                                           min=minValue, max=maxValue)
+                        style = wx.BOTTOM | wx.LEFT | wx.RIGHT
+                        
+                        if p.get('value', '') != '':
+                            txt3.SetValue(int(p['value'])) # parameter previously set
+                        
+                        txt3.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
+                    elif FS:
+                        txt3 = FS.FloatSpin(parent = which_panel, id = wx.ID_ANY,
+                                            size = globalvar.DIALOG_SPIN_SIZE,
+                                            min_val = minValue, max_val = maxValue)
+                        txt3.SetDigits(3)
+                        style = wx.BOTTOM | wx.LEFT | wx.RIGHT
+                        
+                        if p.get('value', '') != '':
+                            txt3.SetValue(float(p['value'])) # parameter previously set
+                        
+                        txt3.Bind(FS.EVT_FLOATSPIN, self.OnSetValue)
+                    else:
+                        txt3 = wx.TextCtrl(parent=which_panel, value = p.get('default',''))
+                        style = wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT
+                        
+                        if p.get('value', '') != '':
+                            txt3.SetValue(str(p['value'])) # parameter previously set
+                    
+                #    txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
                 
                 which_sizer.Add(item=txt3, proportion=0,
                                 flag=style, border=5)



More information about the grass-commit mailing list