[GRASS-SVN] r53508 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 19 09:00:35 PDT 2012


Author: martinl
Date: 2012-10-19 09:00:35 -0700 (Fri, 19 Oct 2012)
New Revision: 53508

Modified:
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI/form: respect `key_desc` for map selector


Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2012-10-19 15:10:32 UTC (rev 53507)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2012-10-19 16:00:35 UTC (rev 53508)
@@ -1120,8 +1120,8 @@
                         selection = gselect.Select(parent = which_panel, id = wx.ID_ANY,
                                                    size = globalvar.DIALOG_GSELECT_SIZE,
                                                    type = p.get('element', ''),
-                                                   multiple = multiple, mapsets = mapsets,
-                                                   fullyQualified = p.get('age', 'old') == 'old')
+                                                   multiple = multiple, nmaps = len(p.get('key_desc', [])),
+                                                   mapsets = mapsets, fullyQualified = p.get('age', 'old') == 'old')
                         
                         value = self._getValue(p)
                         if value:

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2012-10-19 15:10:32 UTC (rev 53507)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2012-10-19 16:00:35 UTC (rev 53508)
@@ -62,17 +62,18 @@
 
 class Select(wx.combo.ComboCtrl):
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
-                 type = None, multiple = False, mapsets = None,
-                 updateOnPopup = True, onPopup = None,
+                 type = None, multiple = False, nmaps = 1,
+                 mapsets = None, updateOnPopup = True, onPopup = None,
                  fullyQualified = True):
         """!Custom control to create a ComboBox with a tree control to
         display and select GIS elements within acessible mapsets.
         Elements can be selected with mouse. Can allow multiple
-        selections, when argument multiple=True. Multiple selections
-        are separated by commas.
+        selections, when argument <em>multiple</em> is True. Multiple
+        selections are separated by commas.
 
         @param type type of GIS elements ('raster, 'vector', ...)
-        @param multiple multiple input allowed?
+        @param multiple True for multiple input
+        @param nmaps number of maps to be entered
         @param mapsets force list of mapsets (otherwise search path)
         @param updateOnPopup True for updating list of elements on popup
         @param onPopup function to be called on Popup
@@ -87,7 +88,7 @@
         self.SetPopupExtents(0, 100)
         if type:
             self.tcp.SetData(type = type, mapsets = mapsets,
-                             multiple = multiple,
+                             multiple = multiple, nmaps = nmaps,
                              updateOnPopup = updateOnPopup, onPopup = onPopup,
                              fullyQualified = fullyQualified)
         self.GetChildren()[0].Bind(wx.EVT_KEY_UP, self.OnKeyUp)
@@ -111,14 +112,14 @@
         """!Load elements"""
         self.tcp.GetElementList()
     
-    def SetType(self, etype, multiple = False, mapsets = None,
-                updateOnPopup = True, onPopup = None):
+    def SetType(self, etype, multiple = False, nmaps = 1,
+                mapsets = None, updateOnPopup = True, onPopup = None):
         """!Param set element type for widget
 
         @param etype element type, see gselect.ElementSelect
         """
         self.tcp.SetData(type = etype, mapsets = mapsets,
-                         multiple = multiple,
+                         multiple = multiple, nmaps = nmaps,
                          updateOnPopup = updateOnPopup, onPopup = onPopup)
         
 class VectorSelect(Select):
@@ -156,6 +157,7 @@
         self.value = [] # for multiple is False -> len(self.value) in [0,1]
         self.curitem = None
         self.multiple = False
+        self.nmaps = 1
         self.type = None
         self.mapsets = None
         self.updateOnPopup = True
@@ -490,11 +492,16 @@
                 if self.fullyQualified:
                     fullName += '@' + self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
                 
-                if self.multiple is True:
-                    # text item should be unique
+                if self.multiple:
                     self.value.append(fullName)
                 else:
-                    self.value = [fullName]
+                    if self.nmaps > 1: #  see key_desc
+                        if len(self.value) >= self.nmaps:
+                            self.value = [fullName]
+                        else:
+                            self.value.append(fullName)
+                    else:
+                        self.value = [fullName]
             
             self.Dismiss()
         
@@ -524,12 +531,17 @@
             if self.fullyQualified:
                 fullName += '@' + self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
             
-            if self.multiple is True:
-                # text item should be unique
+            if self.multiple:
                 self.value.append(fullName)
             else:
-                self.value = [fullName]
-            
+                if self.nmaps > 1: #  see key_desc
+                    if len(self.value) >= self.nmaps:
+                        self.value = [fullName]
+                    else:
+                        self.value.append(fullName)
+                else:
+                    self.value = [fullName]
+        
         self.Dismiss()
         
         evt.Skip()
@@ -542,6 +554,8 @@
             self.mapsets = kargs['mapsets']
         if 'multiple' in kargs:
             self.multiple = kargs['multiple']
+        if 'nmaps' in kargs:
+            self.nmaps = kargs['nmaps']
         if 'updateOnPopup' in kargs:
             self.updateOnPopup = kargs['updateOnPopup']
         if 'onPopup' in kargs:



More information about the grass-commit mailing list