Explorar o código

wxGUI: update onDone methods to pass event as argument

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64373 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa %!s(int64=10) %!d(string=hai) anos
pai
achega
2feff8f820

+ 3 - 3
gui/wxpython/core/gconsole.py

@@ -457,7 +457,6 @@ class GConsole(wx.EvtHandler):
         if command[0] in globalvar.grassCmd:
             # send GRASS command without arguments to GUI command interface
             # except ignored commands (event is emitted)
-
             if self._ignoredCmdPattern and \
               re.compile(self._ignoredCmdPattern).search(' '.join(command)) and \
               '--help' not in command and '--ui' not in command:
@@ -628,7 +627,7 @@ class GConsole(wx.EvtHandler):
                          notification=event.notification)
 
         if event.onDone:
-            event.onDone(cmd=event.cmd, returncode=event.returncode)
+            event.onDone(event)
 
         self.cmdOutputTimer.Stop()
 
@@ -670,7 +669,8 @@ class GConsole(wx.EvtHandler):
                     for lname in lnames:
                         if '@' not in lname:
                             lname += '@' + grass.gisenv()['MAPSET']
-                        self.mapCreated.emit(name=lname, ltype=prompt)
+                        if grass.find_file(lname, element=p.get('element'))['fullname']:
+                            self.mapCreated.emit(name=lname, ltype=prompt)
         if name == 'r.mask':
             self.updateMap.emit()
         

+ 2 - 2
gui/wxpython/gmodeler/frame.py

@@ -503,7 +503,7 @@ class ModelFrame(wx.Frame):
         """Run entire model"""
         self.model.Run(self._gconsole, self.OnDone, parent = self)
         
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Computation finished
 
         .. todo::
@@ -1728,7 +1728,7 @@ class PythonPanel(wx.Panel):
         
         event.Skip()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Python script finished"""
         try_remove(self.filename)
         self.filename = None

+ 2 - 5
gui/wxpython/gui_core/forms.py

@@ -629,13 +629,10 @@ class TaskFrame(wx.Frame):
         if event:
             event.Skip()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """This function is launched from OnRun() when command is
         finished
-
-        :param returncode: command's return code (0 for success)
         """
-
         if hasattr(self, "btn_cancel"):
             self.btn_cancel.Enable(True)
 
@@ -652,7 +649,7 @@ class TaskFrame(wx.Frame):
                     self.get_dcmd is None and \
                     hasattr(self, "closebox") and \
                     self.closebox.IsChecked() and \
-                    (returncode == 0):
+                    (event.returncode == 0):
             # was closed also when aborted but better is leave it open
             wx.FutureCall(2000, self.Close)
 

+ 1 - 1
gui/wxpython/lmgr/frame.py

@@ -496,7 +496,7 @@ class GMFrame(wx.Frame):
         
         win.Show()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Command execution finished"""
         if hasattr(self, "model"):
             self.model.DeleteIntermediateData(log = self._gconsole)

+ 2 - 2
gui/wxpython/modules/extensions.py

@@ -231,8 +231,8 @@ class InstallExtensionWindow(wx.Frame):
         if cmd:
             log.RunCmd(cmd, onDone = self.OnDone)
         
-    def OnDone(self, cmd, returncode):
-        if returncode == 0:
+    def OnDone(self, event):
+        if event.returncode == 0:
             if not os.getenv('GRASS_ADDON_BASE'):
                 SetAddOnPath(key = 'BASE')
             

+ 2 - 2
gui/wxpython/modules/mcalc_builder.py

@@ -593,12 +593,12 @@ class MapCalcFrame(wx.Frame):
             RunCommand(self.cmd,
                        **params)
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Add create map to the layer tree
 
         Sends the mapCreated signal from the grass interface.
         """
-        if returncode != 0:
+        if event.returncode != 0:
             return
         name = self.newmaptxt.GetValue().strip(' "') + '@' + grass.gisenv()['MAPSET']
         ltype = 'raster'

+ 1 - 1
gui/wxpython/modules/vclean.py

@@ -440,7 +440,7 @@ class VectorCleaningFrame(wx.Frame):
         else:
             self.selected = -1
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Command done"""
         self.SetStatusText('')
 

+ 15 - 15
gui/wxpython/vnet/vnet_core.py

@@ -282,15 +282,15 @@ class VNETManager:
 
         return True
 
-    def _createTtbDone(self, cmd, returncode):
+    def _createTtbDone(self, event):
 
-        if returncode != 0:
+        if event.returncode != 0:
             GMessage(parent = self.guiparent,
                      message = _("Creation of turntable failed."))
             return
         else:
             params = {}
-            for c in cmd:
+            for c in event.cmd:
                 spl_c = c.split("=")
                 if len(spl_c) != 2:
                     continue
@@ -302,7 +302,7 @@ class VNETManager:
 
             self.vnet_data.SetParams(params, {})
 
-        self.ttbCreated.emit(returncode = returncode)
+        self.ttbCreated.emit(returncode = event.returncode)
 
     def SaveTmpLayer(self, layer_name):
         """Permanently saves temporary map of analysis result"""
@@ -460,24 +460,24 @@ class VNETAnalyses:
         else:
             self.goutput.RunCmd(command = cmdParams, onDone = self._vnetPathRunAnDone)
 
-    def _vnetPathRunTurnsAnDone(self, cmd, returncode):
+    def _vnetPathRunTurnsAnDone(self, event):
         #TODO
         #self.tmp_maps.DeleteTmpMap(self.tmpTurnAn)
-        self._vnetPathRunAnDone(cmd, returncode)
+        self._vnetPathRunAnDone(event)
 
-    def _vnetPathRunAnDone(self, cmd, returncode):
+    def _vnetPathRunAnDone(self, event):
         """Called when v.net.path analysis is done"""
         try_remove(self.coordsTmpFile)
 
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
-    def _onDone(self, cmd, returncode):
-        for c in cmd:
+    def _onDone(self, event):
+        for c in event.cmd:
             if "output=" in c:
                 output = c.split("=")[1]
                 break  
 
-        self.onAnDone(cmd, returncode, output)
+        self.onAnDone(event.cmd, event.returncode, output)
 
     def _runTurnsAn(self, analysis, output, params, flags, catPts):
 
@@ -585,11 +585,11 @@ class VNETAnalyses:
 
         try_remove(sqlFile)
 
-    def _runTurnsAnDone(self, cmd, returncode):
+    def _runTurnsAnDone(self, event):
         """Called when analysis is done"""
         #self.tmp_maps.DeleteTmpMap(self.tmpTurnAn) #TODO remove earlier (OnDone lambda?)
  
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
 
     def _runAn(self, analysis, output, params, flags, catPts):
@@ -691,7 +691,7 @@ class VNETAnalyses:
         self._prepareCmd(cmdParams)
         self.goutput.RunCmd(command = cmdParams, onDone = self._runAnDone)
 
-    def _runAnDone(self, cmd, returncode):
+    def _runAnDone(self, event):
         """Called when analysis is done"""
         self.tmp_maps.DeleteTmpMap(self.tmpInPts) #TODO remove earlier (OnDone lambda?)
         self.tmp_maps.DeleteTmpMap(self.tmpInPtsConnected)
@@ -700,7 +700,7 @@ class VNETAnalyses:
         if cmd[0] == "v.net.flow":
             self.tmp_maps.DeleteTmpMap(self.vnetFlowTmpCut)
 
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
     def _setInputParams(self, analysis, params, flags):
         """Return list of chosen values (vector map, layers).