Sfoglia il codice sorgente

wxGUI/modeler: fix OnCmdRun/Done

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43271 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 anni fa
parent
commit
9da7626f97
2 ha cambiato i file con 23 aggiunte e 10 eliminazioni
  1. 21 2
      gui/wxpython/gui_modules/gmodeler.py
  2. 2 8
      gui/wxpython/gui_modules/goutput.py

+ 21 - 2
gui/wxpython/gui_modules/gmodeler.py

@@ -630,6 +630,24 @@ class ModelFrame(wx.Frame):
         self.GetCanvas().Refresh()
         self.SetStatusText("", 0)
 
+    def OnCmdRun(self, event):
+        """!Run command"""
+        try:
+            action = self.GetModel().GetItems()[event.pid]
+            if hasattr(action, "task"):
+                action.Update(running = True)
+        except IndexError:
+            pass
+        
+    def OnCmdDone(self, event):
+        """!Command done (or aborted)"""
+        try:
+            action = self.GetModel().GetItems()[event.pid]
+            if hasattr(action, "task"):
+                action.Update(running = True)
+        except IndexError:
+            pass
+        
     def OnCloseWindow(self, event):
         """!Close window"""
         if self.modelChanged and \
@@ -936,7 +954,8 @@ class ModelFrame(wx.Frame):
                 
                 for action in item.GetItems():
                     for vars()[condVar] in eval(condText):
-                        self._runAction(action, params)
+                        if isinstance(action, ModelAction):
+                            self._runAction(action, params)
         
         if params:
             dlg.Destroy()
@@ -948,7 +967,7 @@ class ModelFrame(wx.Frame):
             paramsOrig = item.GetParams(dcopy = True)
             item.MergeParams(params[name])
             
-        self.SetStatusText(_('Running model...'), 0) 
+        self.SetStatusText(_('Running model...'), 0)
         self.goutput.RunCmd(command = item.GetLog(string = False),
                             onDone = self.OnDone)
             

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

@@ -665,10 +665,7 @@ class GMConsole(wx.SplitterWindow):
     def OnCmdRun(self, event):
         """!Run command"""
         if self.parent.GetName() == 'Modeler':
-            try:
-                self.parent.GetModel().GetActions()[event.pid].Update(running = True)
-            except IndexError:
-                pass
+            self.parent.OnCmdRun(event)
         
         self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
         self.btn_abort.Enable()
@@ -676,10 +673,7 @@ class GMConsole(wx.SplitterWindow):
     def OnCmdDone(self, event):
         """!Command done (or aborted)"""
         if self.parent.GetName() == 'Modeler':
-            try:
-                self.parent.GetModel().GetActions()[event.pid].Update(running = False)
-            except IndexError:
-                pass
+            self.parent.OnCmdDone(event)
         
         if event.aborted:
             # Thread aborted (using our convention of None return)