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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 31 19:36:14 PDT 2018


Author: annakrat
Date: 2018-05-31 19:36:14 -0700 (Thu, 31 May 2018)
New Revision: 72754

Modified:
   grass/trunk/gui/wxpython/gui_core/dialogs.py
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: use simpler widget for MapsetSelect to avoid wxWidgets bug #17771 on mac

Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py	2018-06-01 02:28:56 UTC (rev 72753)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py	2018-06-01 02:36:14 UTC (rev 72754)
@@ -110,6 +110,7 @@
             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 @@
 
         # 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)

Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2018-06-01 02:28:56 UTC (rev 72753)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2018-06-01 02:36:14 UTC (rev 72754)
@@ -1708,11 +1708,8 @@
                             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(

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2018-06-01 02:28:56 UTC (rev 72753)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2018-06-01 02:36:14 UTC (rev 72754)
@@ -1229,7 +1229,7 @@
             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 @@
         # 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,13 +1258,24 @@
         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 @@
             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,32 +1309,7 @@
 
         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"""
 



More information about the grass-commit mailing list