Bläddra i källkod

wxGUI: modify MapsetSelect to allow multiple selection

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58618 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 år sedan
förälder
incheckning
147a364e97
2 ändrade filer med 21 tillägg och 9 borttagningar
  1. 3 1
      gui/wxpython/gui_core/forms.py
  2. 18 8
      gui/wxpython/gui_core/gselect.py

+ 3 - 1
gui/wxpython/gui_core/forms.py

@@ -1381,8 +1381,10 @@ class CmdPanel(wx.Panel):
                                 new = False
                             else:
                                 new = True
+                            
                             win = gselect.MapsetSelect(parent = which_panel,
-                                                       value = value, new = new)
+                                                       value = value, new = new,
+                                                       multiple = p.get('multiple', False))
                             win.Bind(wx.EVT_COMBOBOX,     self.OnUpdateSelection)
                             win.Bind(wx.EVT_COMBOBOX,     self.OnSetValue) 
                             win.Bind(wx.EVT_TEXT,         self.OnSetValue)

+ 18 - 8
gui/wxpython/gui_core/gselect.py

@@ -26,7 +26,7 @@ Classes:
  - gselect::CoordinatesSelect
  - gselect::SignatureSelect
 
-(C) 2007-2013 by the GRASS Development Team 
+(C) 2007-2014 by the GRASS Development Team 
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -185,7 +185,6 @@ class ListCtrlComboPopup(wx.combo.ComboPopup):
         self.seltree.Bind(wx.EVT_TREE_DELETE_ITEM, lambda x: None)
         self.seltree.Bind(wx.EVT_TREE_BEGIN_DRAG, lambda x: None)
         self.seltree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, lambda x: None)
-        
 
     def GetControl(self):
         return self.seltree
@@ -248,6 +247,13 @@ class ListCtrlComboPopup(wx.combo.ComboPopup):
             root = self.seltree.AddRoot("<hidden root>")
         self.seltree.AppendItem(root, text = value)
 
+    def SetItems(self, items):
+        root = self.seltree.GetRootItem()
+        if not root:
+            root = self.seltree.AddRoot("<hidden root>")
+        for item in items:
+            self.seltree.AppendItem(root, text = item)
+        
     def OnKeyUp(self, event):
         """!Enable to select items using keyboard
         """
@@ -1060,17 +1066,17 @@ class LocationSelect(wx.ComboBox):
         else:
             self.SetItems([])
         
-class MapsetSelect(wx.ComboBox):
+class MapsetSelect(wx.combo.ComboCtrl):
     """!Widget for selecting GRASS mapset"""
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_COMBOBOX_SIZE, 
                  gisdbase = None, location = None, setItems = True,
-                 searchPath = False, new = False, skipCurrent = False, **kwargs):
+                 searchPath = False, new = False, skipCurrent = False, multiple = False, **kwargs):
         style = 0
-        if not new:
+        if not new and not multiple:
             style = wx.CB_READONLY
         
-        super(MapsetSelect, self).__init__(parent, id, size = size, 
-                                           style = style, **kwargs)
+        wx.combo.ComboCtrl.__init__(self, parent, id, size = size, 
+                                    style = style, **kwargs)
         self.searchPath  = searchPath
         self.skipCurrent = skipCurrent
         
@@ -1085,8 +1091,12 @@ class MapsetSelect(wx.ComboBox):
         else:
             self.location = location
         
+        self.tcp = ListCtrlComboPopup()
+        self.SetPopupControl(self.tcp)
+        self.tcp.SetData(multiple = multiple)
+        
         if setItems:
-            self.SetItems(self._getMapsets())
+            self.tcp.SetItems(self._getMapsets())
         
     def UpdateItems(self, location, dbase = None):
         """!Update list of mapsets for given location