Procházet zdrojové kódy

pyedit: do not use onDone because it is not executed when GUI is invoked (fixes https://trac.osgeo.org/grass/ticket/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, https://trac.osgeo.org/grass/changeset/68395).


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68396 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras před 9 roky
rodič
revize
df1845eac1
1 změnil soubory, kde provedl 6 přidání a 15 odebrání
  1. 6 15
      gui/wxpython/gui_core/pyedit.py

+ 6 - 15
gui/wxpython/gui_core/pyedit.py

@@ -259,14 +259,9 @@ class PyEditController(object):
         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 @@ class PyEditController(object):
         # 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 @@ class PyEditController(object):
 
         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()