Changeset 67232


Ignore:
Timestamp:
Dec 18, 2015, 1:03:00 PM (9 years ago)
Author:
martinl
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/gui/wxpython/core/gconsole.py

    r66936 r67232  
    492492                            return
    493493
    494                 if len(command) == 1 and hasParams and \
    495                         command[0] != 'v.krige':
    496                     # no arguments given
    497                     try:
    498                         GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
    499                     except GException as e:
    500                         print >> sys.stderr, e
    501                     return
    502 
     494                if len(command) == 1:
     495                    if command[0].startswith('g.gui.'):
     496                        import imp
     497                        import inspect
     498                        pyFile = command[0]
     499                        if sys.platform == 'win32':
     500                            pyFile += '.py'
     501                        pyPath = os.path.join(os.environ['GISBASE'], 'scripts', pyFile)
     502                        if not os.path.exists(pyPath):
     503                            pyPath = os.path.join(os.environ['GRASS_ADDON_BASE'], 'scripts', pyFile)
     504                        if not os.path.exists(pyPath):
     505                            GError(parent=self._guiparent,
     506                                   message=_("Module <%s> not found.") % command[0])
     507                        pymodule = imp.load_source(command[0].replace('.', '_'), pyPath)
     508                        pymain = inspect.getargspec(pymodule.main)
     509                        if pymain and 'giface' in pymain.args:
     510                            pymodule.main(self._giface)
     511                            return
     512                   
     513                    if hasParams and command[0] != 'v.krige':
     514                        # no arguments given
     515                        try:
     516                            GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
     517                        except GException as e:
     518                            print >> sys.stderr, e
     519                       
     520                        return
     521               
    503522                # activate computational region (set with g.region)
    504523                # for all non-display commands.
Note: See TracChangeset for help on using the changeset viewer.