[GRASS-SVN] r68396 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 7 11:52:46 PDT 2016


Author: wenzeslaus
Date: 2016-05-07 11:52:46 -0700 (Sat, 07 May 2016)
New Revision: 68396

Modified:
   grass/trunk/gui/wxpython/gui_core/pyedit.py
Log:
pyedit: do not use onDone because it is not executed when GUI is invoked (fixes #2997)

Now you can run again even if it is already running
which is the same behavior as for normal module calls.

It also uses the same temporary file once it was created
to avoid the need to delete it all the time. It is deleted
when file is actually saved.

Also remove suppression of the GUI interface because we
actually want to get GUI (the parameter does not work, r68395).


Modified: grass/trunk/gui/wxpython/gui_core/pyedit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/pyedit.py	2016-05-07 18:31:53 UTC (rev 68395)
+++ grass/trunk/gui/wxpython/gui_core/pyedit.py	2016-05-07 18:52:46 UTC (rev 68396)
@@ -259,14 +259,9 @@
         self.body = panel
         self.filename = None
         self.tempfile = None  # bool, make them strings for better code
-        self.running = False
 
     def OnRun(self, event):
         """Run Python script"""
-        if self.running:
-            # ignore when already running
-            return
-
         if not self.filename:
             self.filename = gscript.tempfile() + '.py'
             self.tempfile = True
@@ -294,19 +289,15 @@
         # TODO: add overwrite to toolbar, needs env in GConsole
         # run in console as other modules, avoid Python shell which
         # carries variables over to the next execution
-        self.giface.RunCmd([fd.name], skipInterface=True, onDone=self.OnDone)
-        self.running = True
+        self.giface.RunCmd([fd.name])
 
-    def OnDone(self, event):
-        """Python script finished"""
+    def SaveAs(self):
+        """Save python script to file"""
         if self.tempfile:
             try_remove(self.filename)
-            self.filename = None
-        self.running = False
+            self.tempfile = False
 
-    def SaveAs(self):
-        """Save python script to file"""
-        filename = ''
+        filename = None
         dlg = wx.FileDialog(parent=self.guiparent,
                             message=_("Choose file to save"),
                             defaultDir=os.getcwd(),
@@ -357,7 +348,7 @@
 
         Just save if file already specified, save as action otherwise.
         """
-        if self.filename:
+        if self.filename and not self.tempfile:
             self.Save()
         else:
             self.SaveAs()



More information about the grass-commit mailing list