[GRASS-SVN] r53509 - grass/branches/develbranch_6/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 19 09:04:01 PDT 2012


Author: martinl
Date: 2012-10-19 09:04:01 -0700 (Fri, 19 Oct 2012)
New Revision: 53509

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py
Log:
wxGUI/form: respect `key_desc` for map selector
            (merge r53508 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py	2012-10-19 16:00:35 UTC (rev 53508)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py	2012-10-19 16:04:01 UTC (rev 53509)
@@ -1106,8 +1106,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')
                         
                         
                         # A select.Select is a combobox with two children: a textctl and a popupwindow;

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py	2012-10-19 16:00:35 UTC (rev 53508)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py	2012-10-19 16:04:01 UTC (rev 53509)
@@ -56,17 +56,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
@@ -81,7 +82,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)
@@ -105,14 +106,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):
@@ -150,6 +151,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
@@ -480,11 +482,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()
         
@@ -514,12 +521,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()
@@ -532,6 +544,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