[GRASS-SVN] r39782 - in grass/trunk/gui/wxpython: . gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 22 12:03:16 EST 2009
Author: martinl
Date: 2009-11-22 12:03:16 -0500 (Sun, 22 Nov 2009)
New Revision: 39782
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/wxgui.py
grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: run script item added to the menu
(merge r39781 from devbr6)
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-11-22 16:57:03 UTC (rev 39781)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-11-22 17:03:16 UTC (rev 39782)
@@ -413,17 +413,13 @@
else:
# Send any other command to the shell. Send output to
# console output window
-
- # if command is not a GRASS command, treat it like a shell command
- # process GRASS command with argument
+
self.cmdThread.RunCmd(GrassCmd,
onDone,
cmdlist,
self.cmd_stdout, self.cmd_stderr)
self.btn_abort.Enable()
self.cmd_output_timer.Start(50)
-
- return None
return None
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2009-11-22 16:57:03 UTC (rev 39781)
+++ grass/trunk/gui/wxpython/wxgui.py 2009-11-22 17:03:16 UTC (rev 39782)
@@ -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/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml 2009-11-22 16:57:03 UTC (rev 39781)
+++ grass/trunk/gui/wxpython/xml/menudata.xml 2009-11-22 17:03:16 UTC (rev 39782)
@@ -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