[GRASS-SVN] r39781 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 22 11:57:04 EST 2009


Author: martinl
Date: 2009-11-22 11:57:03 -0500 (Sun, 22 Nov 2009)
New Revision: 39781

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: run script item added to the menu


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2009-11-21 19:45:56 UTC (rev 39780)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2009-11-22 16:57:03 UTC (rev 39781)
@@ -415,9 +415,15 @@
 
             # if command is not a GRASS command, treat it like a shell command
             try:
-                gcmd.Command(cmdlist,
-                             stdout=self.cmd_stdout,
-                             stderr=self.cmd_stderr)
+                # gcmd.Command(cmdlist,
+                #             stdout=self.cmd_stdout,
+                #             stderr=self.cmd_stderr)
+                self.cmdThread.RunCmd(GrassCmd,
+                                      onDone,
+                                      cmdlist,
+                                      self.cmd_stdout, self.cmd_stderr)
+                self.btn_abort.Enable()
+                self.cmd_output_timer.Start(50)
             except gcmd.CmdError, e:
                 print >> sys.stderr, e
         

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2009-11-21 19:45:56 UTC (rev 39780)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2009-11-22 16:57:03 UTC (rev 39781)
@@ -464,6 +464,28 @@
             cmd = self.GetMenuCmd(event)
         menuform.GUI().ParseCommand(cmd, parentframe=self)
 
+    def OnRunScript(self, event):
+        """!Run script"""
+        # open dialog and choose script file
+        dlg = wx.FileDialog(parent = self, message = _("Choose script file"),
+                            defaultDir = os.getcwd(), wildcard = "Bash script (*.sh)|*.sh|Python script (*.py)|*.py")
+        
+        filename = None
+        if dlg.ShowModal() == wx.ID_OK:
+            filename = dlg.GetPath()
+        
+        if not filename:
+            return False
+
+        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)
+            return
+        
+        self.goutput.WriteCmdLog(_("Launching script '%s'...") % filename)
+        self.goutput.RunCmd(filename, switchPage = True)
+        
     def OnChangeLocation(self, event):
         """Change current location"""
         dlg = gdialogs.LocationDialog(parent = self)

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2009-11-21 19:45:56 UTC (rev 39780)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2009-11-22 16:57:03 UTC (rev 39781)
@@ -643,6 +643,12 @@
 	</menuitem>
 	<separator />
 	<menuitem>
+	  <label>Launch script</label>
+	  <help>Launches script file.</help>
+	  <handler>self.OnRunScript</handler>
+	</menuitem>
+	<separator />
+	<menuitem>
 	  <label>Quit GUI</label>
 	  <help>Quit wxGUI session</help>
 	  <handler>self.OnCloseWindow</handler>



More information about the grass-commit mailing list