Selaa lähdekoodia

wxGUI: implement mechanism which allows to pass giface to g.gui.* modules

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67232 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 vuotta sitten
vanhempi
commit
13df30919b
1 muutettua tiedostoa jossa 28 lisäystä ja 9 poistoa
  1. 28 9
      gui/wxpython/core/gconsole.py

+ 28 - 9
gui/wxpython/core/gconsole.py

@@ -491,15 +491,34 @@ class GConsole(wx.EvtHandler):
                                                                       'opt': p.get('name', '')})
                                                                       'opt': p.get('name', '')})
                             return
                             return
 
 
-                if len(command) == 1 and hasParams and \
-                        command[0] != 'v.krige':
-                    # no arguments given
-                    try:
-                        GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
-                    except GException as e:
-                        print >> sys.stderr, e
-                    return
-
+                if len(command) == 1:
+                    if command[0].startswith('g.gui.'):
+                        import imp
+                        import inspect
+                        pyFile = command[0]
+                        if sys.platform == 'win32':
+                            pyFile += '.py'
+                        pyPath = os.path.join(os.environ['GISBASE'], 'scripts', pyFile)
+                        if not os.path.exists(pyPath):
+                            pyPath = os.path.join(os.environ['GRASS_ADDON_BASE'], 'scripts', pyFile)
+                        if not os.path.exists(pyPath):
+                            GError(parent=self._guiparent,
+                                   message=_("Module <%s> not found.") % command[0])
+                        pymodule = imp.load_source(command[0].replace('.', '_'), pyPath)
+                        pymain = inspect.getargspec(pymodule.main)
+                        if pymain and 'giface' in pymain.args:
+                            pymodule.main(self._giface)
+                            return
+                    
+                    if hasParams and command[0] != 'v.krige':
+                        # no arguments given
+                        try:
+                            GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
+                        except GException as e:
+                            print >> sys.stderr, e
+                        
+                        return
+                
                 # activate computational region (set with g.region)
                 # activate computational region (set with g.region)
                 # for all non-display commands.
                 # for all non-display commands.
                 if compReg:
                 if compReg: