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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 28 09:06:53 EDT 2011


Author: mmetz
Date: 2011-06-28 06:06:53 -0700 (Tue, 28 Jun 2011)
New Revision: 46823

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
layer input option: support for native vectors

Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2011-06-28 10:30:07 UTC (rev 46822)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2011-06-28 13:06:53 UTC (rev 46823)
@@ -663,10 +663,15 @@
                                   fs = '|',
                                   flags = 'g',
                                   map = vector)
-            for line in ret.splitlines():
-                layerinfo = line.split('|')
-                layername = layerinfo[0].split('/')
-                layers.append(layername[len(layername) - 1])
+            if ret:
+                for line in ret.splitlines():
+                    layerinfo = line.split('|')
+                    layername = layerinfo[0].split('/')
+                    # use this to get layer names
+                    # but only when all modules use Vect_get_field2()
+                    # which is not the case right now
+                    ### layers.append(layername[len(layername) - 1])
+                    layers.append(layername[0])
             
         elif dsn:
             ret = gcmd.RunCommand('v.in.ogr',

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-06-28 10:30:07 UTC (rev 46822)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-06-28 13:06:53 UTC (rev 46823)
@@ -237,18 +237,18 @@
                         if p.get('element', '') == 'layer':
                             layer = p.get('value', '')
                             if layer != '':
-                                layer = p.get('value', 1)
+                                layer = p.get('value', '')
                             else:
-                                layer = p.get('default', 1)
+                                layer = p.get('default', '')
                             break
                         
                 elif p.get('element', '') == 'layer': # -> layer
                     # get layer
                     layer = p.get('value', '')
                     if layer != '':
-                        layer = p.get('value', 1)
+                        layer = p.get('value', '')
                     else:
-                        layer = p.get('default', 1)
+                        layer = p.get('default', '')
                     
                     # get map name
                     pMap = self.task.get_param(p['wxId'][0], element = 'wxId-bind', raiseError = False)
@@ -278,16 +278,16 @@
                         native = False
                         break
                 # TODO: update only if needed
-                #if native:
-                #    if map:
-                #        self.data[win.InsertLayers] = { 'vector' : map }
-                #    else:
-                #        self.data[win.InsertLayers] = { }
-                #else:
-                #    if map:
-                #        self.data[win.InsertLayers] = { 'dsn' : map.rstrip('@OGR') }
-                #    else:
-                #        self.data[win.InsertLayers] = { }
+                if native:
+                    if map:
+                        self.data[win.InsertLayers] = { 'vector' : map }
+                    else:
+                        self.data[win.InsertLayers] = { }
+                else:
+                    if map:
+                        self.data[win.InsertLayers] = { 'dsn' : map.rstrip('@OGR') }
+                    else:
+                        self.data[win.InsertLayers] = { }
             
             elif name == 'TableSelect':
                 self.data[win.InsertTables] = { 'driver' : driver,
@@ -1029,7 +1029,7 @@
                 
                 self.goutput.RunCmd(cmd, onDone = self.OnDone)
             except AttributeError, e:
-                print >> sys.stderr, "%s: Propably not running in wxgui.py session?" % (e)
+                print >> sys.stderr, "%s: Probably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
         else:
             gcmd.Command(cmd)
@@ -1553,9 +1553,7 @@
                                           size = globalvar.DIALOG_TEXTCTRL_SIZE)
                         win.Bind(wx.EVT_TEXT, self.OnSetValue)
                     else:
-                        value = p.get('value', '')
-                        if not value:
-                            value = p.get('default', '')
+                        value = self._getValue(p)
                         
                         if p.get('prompt', '') in ('layer',
                                                    'layer_all'):
@@ -1567,15 +1565,14 @@
                                 win = gselect.LayerSelect(parent = which_panel,
                                                           all = all,
                                                           default = p['default'])
-                                win.Bind(wx.EVT_COMBOBOX, self.OnUpdateSelection)
-                                win.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
+                                win.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
+                                win.Bind(wx.EVT_TEXT, self.OnSetValue)
                             else:
                                 win = wx.SpinCtrl(parent = which_panel, id = wx.ID_ANY,
                                                   min = 1, max = 100, initial = int(p['default']))
                                 win.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
-                            if p.get('value','') ==  '':
-                                win.SetItems([p['value']])
-                                win.SetSelection(0)
+
+                            win.SetValue(str(value))
                             
                             p['wxId'] = [ win.GetId() ]
 
@@ -2069,13 +2066,15 @@
         if not found:
             return
         
-        if name in ('LayerSelect', 'DriverSelect', 'TableSelect',
+        if name in ('DriverSelect', 'TableSelect',
                     'LocationSelect', 'MapsetSelect', 'ProjSelect'):
             porf['value'] = me.GetStringSelection()
         elif name ==  'GdalSelect':
             porf['value'] = event.dsn
         elif name ==  'ModelParam':
             porf['parameterized'] = me.IsChecked()
+        elif name ==  'LayerSelect':
+            porf['value'] = me.GetValue()
         else:
             porf['value'] = me.GetValue()
         



More information about the grass-commit mailing list