Parcourir la source

wxGUI/mapcalc: fix inserting operands

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42192 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa il y a 15 ans
Parent
commit
ab7b584a2a
1 fichiers modifiés avec 9 ajouts et 10 suppressions
  1. 9 10
      gui/wxpython/gui_modules/mcalc_builder.py

+ 9 - 10
gui/wxpython/gui_modules/mcalc_builder.py

@@ -345,31 +345,30 @@ class MapCalcFrame(wx.Frame):
         """
         item = event.GetString()
         self._addSomething(item)
-        self.text_mcalc.SetFocus()
         
     def _addSomething(self,what):
         """!Inserts operators, map names, and functions into text area
         """
         self.text_mcalc.SetFocus()
-        mcalcstr = self.text_mcalc.GetValue()
-        newmcalcstr = ''
-        position = self.text_mcalc.GetInsertionPoint()
+        mcalcstr  = self.text_mcalc.GetValue()
+        position  = self.text_mcalc.GetInsertionPoint()
         
-        selection = self.text_mcalc.GetSelection()
-
         newmcalcstr = mcalcstr[:position]
         
+        position_offset = 0
         try:
             if newmcalcstr[-1] != ' ':
-                newmcalcstr += " "
+                newmcalcstr += ' '
+                position_offset += 1
         except:
             pass
+        
         newmcalcstr += what
-        position_offset = len(what)
-        newmcalcstr += " " + mcalcstr[position:]
+        position_offset += len(what)
+        newmcalcstr += ' ' + mcalcstr[position:]
         
         self.text_mcalc.SetValue(newmcalcstr)
-        self.text_mcalc.SetInsertionPoint(position+position_offset)
+        self.text_mcalc.SetInsertionPoint(position + position_offset)
         self.text_mcalc.Update()
         
     def OnMCalcRun(self,event):