Bläddra i källkod

wxGUI: fix running scripts
(merge https://trac.osgeo.org/grass/changeset/44253 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44255 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 år sedan
förälder
incheckning
7e0e0005a3
3 ändrade filer med 16 tillägg och 13 borttagningar
  1. 5 8
      gui/wxpython/gui_modules/goutput.py
  2. 6 0
      gui/wxpython/gui_modules/prompt.py
  3. 5 5
      gui/wxpython/wxgui.py

+ 5 - 8
gui/wxpython/gui_modules/goutput.py

@@ -530,14 +530,11 @@ class GMConsole(wx.SplitterWindow):
         else:
         else:
             # Send any other command to the shell. Send output to
             # Send any other command to the shell. Send output to
             # console output window
             # console output window
-            if grass.find_program(command[0]):
-                self.cmdThread.RunCmd(GrassCmd,
-                                      onDone,
-                                      command,
-                                      self.cmd_stdout, self.cmd_stderr)                                         
-                self.cmd_output_timer.Start(50)
-            else:
-                self.WriteError(_("Command '%s' not found") % command[0])
+            self.cmdThread.RunCmd(GrassCmd,
+                                  onDone,
+                                  command,
+                                  self.cmd_stdout, self.cmd_stderr)                                         
+            self.cmd_output_timer.Start(50)
         
         
         return None
         return None
 
 

+ 6 - 0
gui/wxpython/gui_modules/prompt.py

@@ -791,6 +791,11 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
             # Autocompletion for map/data file name entry after '=', ',', or manually
             # Autocompletion for map/data file name entry after '=', ',', or manually
             pos = self.GetCurrentPos()
             pos = self.GetCurrentPos()
             entry = self.GetTextLeft()
             entry = self.GetTextLeft()
+            if 'r.mapcalc' in entry:
+                self.InsertText(pos, '=')
+                self.CharRight()
+                return
+            
             if event.GetKeyCode() != 44:
             if event.GetKeyCode() != 44:
                 self.promptType = None
                 self.promptType = None
             
             
@@ -911,6 +916,7 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
             if len(items) == 1:
             if len(items) == 1:
                 cmd = items[0].strip()
                 cmd = items[0].strip()
                 if cmd in globalvar.grassCmd['all'] and \
                 if cmd in globalvar.grassCmd['all'] and \
+                        cmd != 'r.mapcalc' and \
                         (not self.cmdDesc or cmd != self.cmdDesc.get_name()):
                         (not self.cmdDesc or cmd != self.cmdDesc.get_name()):
                     try:
                     try:
                         self.cmdDesc = menuform.GUI().ParseInterface(cmd = [cmd])
                         self.cmdDesc = menuform.GUI().ParseInterface(cmd = [cmd])

+ 5 - 5
gui/wxpython/wxgui.py

@@ -433,7 +433,7 @@ class GMFrame(wx.Frame):
     def OnRunScript(self, event):
     def OnRunScript(self, event):
         """!Run script"""
         """!Run script"""
         # open dialog and choose script file
         # open dialog and choose script file
-        dlg = wx.FileDialog(parent = self, message = _("Choose script file"),
+        dlg = wx.FileDialog(parent = self, message = _("Choose script file to run"),
                             defaultDir = os.getcwd(),
                             defaultDir = os.getcwd(),
                             wildcard = _("Python script (*.py)|*.py|Bash script (*.sh)|*.sh"))
                             wildcard = _("Python script (*.py)|*.py|Bash script (*.sh)|*.sh"))
         
         
@@ -445,13 +445,13 @@ class GMFrame(wx.Frame):
             return False
             return False
 
 
         if not os.path.exists(filename):
         if not os.path.exists(filename):
-            wx.MessageBox(parent = self,
-                          message = _("Script file '%s' doesn't exist. Operation cancelled.") % filename,
-                          caption = _("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+            gcmd.GError(parent = self,
+                        message = _("Script file '%s' doesn't exist. "
+                                    "Operation cancelled.") % filename)
             return
             return
         
         
         self.goutput.WriteCmdLog(_("Launching script '%s'...") % filename)
         self.goutput.WriteCmdLog(_("Launching script '%s'...") % filename)
-        self.goutput.RunCmd(filename, switchPage = True)
+        self.goutput.RunCmd([filename], switchPage = True)
         
         
     def OnChangeLocation(self, event):
     def OnChangeLocation(self, event):
         """Change current location"""
         """Change current location"""