Pārlūkot izejas kodu

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 10 gadi atpakaļ
vecāks
revīzija
2feff8f820

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

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

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

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

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

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

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

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

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

@@ -231,8 +231,8 @@ class InstallExtensionWindow(wx.Frame):
         if cmd:
         if cmd:
             log.RunCmd(cmd, onDone = self.OnDone)
             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'):
             if not os.getenv('GRASS_ADDON_BASE'):
                 SetAddOnPath(key = 'BASE')
                 SetAddOnPath(key = 'BASE')
             
             

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

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

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

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

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

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