[GRASS-SVN] r72856 - grass/branches/releasebranch_7_4/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jun 17 12:56:31 PDT 2018
Author: annakrat
Date: 2018-06-17 12:56:31 -0700 (Sun, 17 Jun 2018)
New Revision: 72856
Modified:
grass/branches/releasebranch_7_4/gui/wxpython/gui_core/dialogs.py
grass/branches/releasebranch_7_4/gui/wxpython/gui_core/forms.py
grass/branches/releasebranch_7_4/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: use simpler widget for MapsetSelect to avoid wxWidgets bug #17771 on mac (merge from trunk, see #3471)
Modified: grass/branches/releasebranch_7_4/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/gui_core/dialogs.py 2018-06-17 19:51:21 UTC (rev 72855)
+++ grass/branches/releasebranch_7_4/gui/wxpython/gui_core/dialogs.py 2018-06-17 19:56:31 UTC (rev 72856)
@@ -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/branches/releasebranch_7_4/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/gui_core/forms.py 2018-06-17 19:51:21 UTC (rev 72855)
+++ grass/branches/releasebranch_7_4/gui/wxpython/gui_core/forms.py 2018-06-17 19:56:31 UTC (rev 72856)
@@ -1706,11 +1706,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/branches/releasebranch_7_4/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/branches/releasebranch_7_4/gui/wxpython/gui_core/gselect.py 2018-06-17 19:51:21 UTC (rev 72855)
+++ grass/branches/releasebranch_7_4/gui/wxpython/gui_core/gselect.py 2018-06-17 19:56:31 UTC (rev 72856)
@@ -1226,7 +1226,7 @@
self.SetItems([])
-class MapsetSelect(ComboCtrl):
+class MapsetSelect(wx.ComboBox):
"""Widget for selecting GRASS mapset"""
def __init__(self, parent, id=wx.ID_ANY,
@@ -1238,11 +1238,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:
@@ -1253,13 +1255,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
@@ -1271,12 +1284,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:
@@ -1295,32 +1306,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