[GRASS-SVN] r55870 - grass/trunk/gui/wxpython/modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 17 23:42:19 PDT 2013


Author: annakrat
Date: 2013-04-17 23:42:18 -0700 (Wed, 17 Apr 2013)
New Revision: 55870

Modified:
   grass/trunk/gui/wxpython/modules/mcalc_builder.py
Log:
wxGUI/mapcalc: fix cursor position when adding function

Modified: grass/trunk/gui/wxpython/modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/modules/mcalc_builder.py	2013-04-18 06:34:05 UTC (rev 55869)
+++ grass/trunk/gui/wxpython/modules/mcalc_builder.py	2013-04-18 06:42:18 UTC (rev 55870)
@@ -18,15 +18,17 @@
 
 import os
 import sys
+import re
 
 import wx
 import grass.script as grass
 
 if __name__ == "__main__":
-    sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'wxpython'))
+    sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython'))
 
 from core             import globalvar
 from core.gcmd        import GError, RunCommand
+from core.giface      import StandaloneGrassInterface
 from gui_core.gselect import Select
 from gui_core.forms   import GUI
 from core.settings    import UserSettings
@@ -460,11 +462,15 @@
             pass
         
         newmcalcstr += what + ' ' + mcalcstr[position:]
-        position_offset += len(what)
         
         self.text_mcalc.SetValue(newmcalcstr)
-        if len(what) > 1 and what[-2:] == '()':
-            position_offset -= 1
+        if len(what) > 1:
+            match = re.search(pattern="\(.*\)", string=what)
+            if match:
+                position_offset += match.start() + 1
+            else:
+                position_offset += len(what)
+
         self.text_mcalc.SetInsertionPoint(position + position_offset)
         self.text_mcalc.Update()
         
@@ -591,6 +597,6 @@
     gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
     
     app = wx.App(0)
-    frame = MapCalcFrame(parent = None, cmd = 'r.mapcalc')
+    frame = MapCalcFrame(parent = None, cmd = 'r.mapcalc', giface = StandaloneGrassInterface())
     frame.Show()
     app.MainLoop()



More information about the grass-commit mailing list