Bladeren bron

wxGUI: use simpler widget for MapsetSelect to avoid wxWidgets bug https://trac.osgeo.org/grass/ticket/17771 on mac

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72754 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 jaren geleden
bovenliggende
commit
fac41cb836
3 gewijzigde bestanden met toevoegingen van 26 en 41 verwijderingen
  1. 2 0
      gui/wxpython/gui_core/dialogs.py
  2. 1 4
      gui/wxpython/gui_core/forms.py
  3. 23 37
      gui/wxpython/gui_core/gselect.py

+ 2 - 0
gui/wxpython/gui_core/dialogs.py

@@ -110,6 +110,7 @@ class LocationDialog(SimpleDialog):
             validator=SimpleValidator(
                 callback=self.ValidatorCallback))
         self.element1.Bind(wx.EVT_TEXT, self.OnLocation)
+        self.element1.Bind(wx.EVT_COMBOBOX, self.OnLocation)
         self.element2 = MapsetSelect(
             parent=self.panel,
             id=wx.ID_ANY,
@@ -1532,6 +1533,7 @@ class MapLayersDialogBase(wx.Dialog):
 
         # bindings
         self.mapset.Bind(wx.EVT_TEXT, self.OnChangeParams)
+        self.mapset.Bind(wx.EVT_COMBOBOX, self.OnChangeParams)
         self.layers.Bind(wx.EVT_RIGHT_DOWN, self.OnMenu)
         self.filter.Bind(wx.EVT_TEXT, self.OnFilter)
         self.toggle.Bind(wx.EVT_CHECKBOX, self.OnToggle)

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

@@ -1708,11 +1708,8 @@ class CmdPanel(wx.Panel):
                             win = gselect.MapsetSelect(
                                 parent=which_panel, value=value, new=new,
                                 multiple=p.get('multiple', False))
-                            textWin = win.GetTextCtrl()
-                            p['wxId'] = [textWin.GetId(), win.GetId()]
-
-                            textWin.Bind(wx.EVT_TEXT, self.OnSetValue)
                             win.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
+                            win.Bind(wx.EVT_TEXT, self.OnSetValue)
 
                         elif prompt == 'dbase':
                             win = gselect.DbaseSelect(

+ 23 - 37
gui/wxpython/gui_core/gselect.py

@@ -1229,7 +1229,7 @@ class LocationSelect(wx.ComboBox):
             self.SetItems([])
 
 
-class MapsetSelect(ComboCtrl):
+class MapsetSelect(wx.ComboBox):
     """Widget for selecting GRASS mapset"""
 
     def __init__(self, parent, id=wx.ID_ANY,
@@ -1241,11 +1241,13 @@ class MapsetSelect(ComboCtrl):
         # if not new and not multiple:
         ###     style = wx.CB_READONLY
 
-        ComboCtrl.__init__(self, parent, id, size=size,
-                           style=style, **kwargs)
+        wx.ComboBox.__init__(self, parent, id, size=size,
+                             style=style, **kwargs)
         self.searchPath = searchPath
         self.skipCurrent = skipCurrent
         self.SetName("MapsetSelect")
+        self.value = ''
+        self.multiple = multiple
         if not gisdbase:
             self.gisdbase = grass.gisenv()['GISDBASE']
         else:
@@ -1256,12 +1258,23 @@ class MapsetSelect(ComboCtrl):
         else:
             self.location = location
 
-        self.tcp = ListCtrlComboPopup()
-        self.SetPopupControl(self.tcp)
-        self.tcp.SetData(multiple=multiple)
-
         if setItems:
-            self.tcp.SetItems(self._getMapsets())
+            self.SetItems(self._getMapsets())
+
+        if self.multiple:
+            self.Bind(wx.EVT_COMBOBOX, self._onSelection)
+            self.Bind(wx.EVT_TEXT, self._onSelection)
+
+    def _onSelection(self, event):
+        value = self.GetValue()
+        if value:
+            if self.value:
+                self.value += ','
+            self.value += value
+            self.SetValue(self.value)
+        else:
+            self.value = value
+        event.Skip()
 
     def UpdateItems(self, location, dbase=None):
         """Update list of mapsets for given location
@@ -1274,12 +1287,10 @@ class MapsetSelect(ComboCtrl):
             self.gisdbase = dbase
         self.location = location
 
-        self.tcp.DeleteAllItems()
-
         if location:
-            self.tcp.SetItems(self._getMapsets())
+            self.SetItems(self._getMapsets())
         else:
-            self.tcp.SetItems([])
+            self.SetItems([])
 
     def _getMapsets(self):
         if self.searchPath:
@@ -1298,31 +1309,6 @@ class MapsetSelect(ComboCtrl):
 
         return mlist
 
-    def GetStringSelection(self):
-        """For backward compatibility. MapsetSelect changed to allow
-        multiple selection, this required to change super-class from
-        wx.ComboBox to wx.combo.ComboCtrl"""
-        return self.GetValue()
-
-    def SetStringSelection(self, text):
-        """For backward compatibility. MapsetSelect changed to allow
-        multiple selection, this required to change super-class from
-        wx.ComboBox to wx.combo.ComboCtrl"""
-        return self.SetValue(text)
-
-    def SetSelection(self, sel=0):
-        """For backward compatibility. MapsetSelect changed to allow
-        multiple selection, this required to change super-class from
-        wx.ComboBox to wx.combo.ComboCtrl"""
-        self.SetValue('')  # TODO: implement SetSelection()
-
-    def SetItems(self, items):
-        """For backward compatibility. MapsetSelect changed to allow
-        multiple selection, this required to change super-class from
-        wx.ComboBox to wx.combo.ComboCtrl"""
-        self.tcp.DeleteAllItems()
-        self.tcp.SetItems(items)
-
 
 class SubGroupSelect(wx.ComboBox):
     """Widget for selecting subgroups"""