[GRASS-SVN] r52807 - grass/trunk/gui/wxpython/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 21 03:43:44 PDT 2012
Author: annakrat
Date: 2012-08-21 03:43:43 -0700 (Tue, 21 Aug 2012)
New Revision: 52807
Modified:
grass/trunk/gui/wxpython/modules/mcalc_builder.py
Log:
wxGUI/mapcalc: fix #1305, improving focus problem when adding map
Modified: grass/trunk/gui/wxpython/modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/modules/mcalc_builder.py 2012-08-21 10:07:02 UTC (rev 52806)
+++ grass/trunk/gui/wxpython/modules/mcalc_builder.py 2012-08-21 10:43:43 UTC (rev 52807)
@@ -111,6 +111,11 @@
element = 'rast3d'
else:
element = 'cell'
+
+ # characters which can be in raster map name but the map name must be then quoted
+ self.charactersToQuote = '+-&!<>%~?^|'
+ # stores last typed map name in Select widget to distinguish typing from selection
+ self.lastMapName = ''
self.operatorBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
label=" %s " % _('Operators'))
@@ -244,7 +249,7 @@
self.btn_save.Bind(wx.EVT_BUTTON, self.OnSaveExpression)
self.btn_load.Bind(wx.EVT_BUTTON, self.OnLoadExpression)
- self.mapselect.Bind(wx.EVT_TEXT, self.OnSelect)
+ self.mapselect.Bind(wx.EVT_TEXT, self.OnSelectTextEvt)
self.function.Bind(wx.EVT_COMBOBOX, self._return_funct)
self.function.Bind(wx.EVT_TEXT_ENTER, self.OnSelect)
self.newmaptxt.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
@@ -404,11 +409,26 @@
elif event.GetId() == self.btn['parenr'].GetId(): mark = ")"
self._addSomething(mark)
+ def OnSelectTextEvt(self, event):
+ """!Checks if user is typing or the event was emited by map selection.
+ Prevents from changing focus.
+ """
+ item = event.GetString()
+ if not (abs(len(item) - len(self.lastMapName)) == 1 and \
+ self.lastMapName in item or item in self.lastMapName):
+ self.OnSelect(event)
+ self.lastMapName = item
+
def OnSelect(self, event):
"""!Gets raster map or function selection and send it to
- insertion method
+ insertion method.
+
+ Checks for characters which can be in raster map name but
+ the raster map name must be then quoted.
"""
- item = event.GetString()
+ item = event.GetString().strip()
+ if any((char in item) for char in self.charactersToQuote):
+ item = '"' + item + '"'
self._addSomething(item)
def OnUpdateStatusBar(self, event):
More information about the grass-commit
mailing list