[GRASS-SVN] r42541 - in grass/trunk/gui/wxpython: gui_modules icons

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 13 05:14:22 EDT 2010


Author: martinl
Date: 2010-06-10 10:27:07 +0000 (Thu, 10 Jun 2010)
New Revision: 42541

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
   grass/trunk/gui/wxpython/icons/icon.py
Log:
wxGUI/model: run model with variables


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-06-10 06:56:53 UTC (rev 42540)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-06-10 10:27:07 UTC (rev 42541)
@@ -37,6 +37,7 @@
 import textwrap
 import tempfile
 import copy
+import re
 
 try:
     import xml.etree.ElementTree as etree
@@ -171,6 +172,7 @@
                                      height = action['size'][1],
                                      task = action['task'],
                                      id = action['id'])
+            
             if action['disabled']:
                 actionItem.Enable(False)
             
@@ -193,6 +195,7 @@
             
             actionItem.SetValid(valid)
             actionItem.SetParameterized(parameterized)
+            actionItem.GetLog() # substitute variables (-> valid/invalid)
         
         # load data & relations
         for data in gxmXml.data:
@@ -305,6 +308,33 @@
         """!Return parameterized options"""
         result = dict()
         idx = 0
+        if self.variables:
+            params = list()
+            result[_("Variables")] = { 'flags'  : list(),
+                                       'params' : params,
+                                       'idx' : idx }
+            for name, values in self.variables.iteritems():
+                params.append({ 'gisprompt' : False,
+                                'multiple'  : 'no',
+                                'description' : values.get('description', ''),
+                                'guidependency' : '',
+                                'default' : values.get('value', ''),
+                                'age' : None,
+                                'required' : 'yes',
+                                'value' : '',
+                                'label' : '',
+                                'guisection' : '',
+                                'key_desc' : '',
+                                'values' : list(),
+                                'parameterized' : False,
+                                'values_desc' : list(),
+                                'prompt' : None,
+                                'element' : None,
+                                'type' : values.get('type', 'string'),
+                                'name' : name })
+            
+            idx += 1
+        
         for action in self.actions:
             if not action.IsEnabled():
                 continue
@@ -1374,6 +1404,19 @@
     def GetLog(self, string = True):
         """!Get logging info"""
         cmd = self.task.getCmd(ignoreErrors = True)
+        # substitute variables
+        variables = self.parent.GetVariables()
+        for variable in variables:
+            pattern= re.compile('%' + variable)
+            value = variables[variable].get('value', '')
+            for idx in range(len(cmd)):
+                if pattern.search(cmd[idx]):
+                    if value:
+                        cmd[idx] = pattern.sub(value, cmd[idx])
+                    else:
+                        self.isValid = False
+                        break
+                idx += 1
         if string:
             if cmd is None:
                 return ''
@@ -2840,7 +2883,10 @@
     
     def _createPage(self, name, params):
         """!Define notebook page"""
-        task = menuform.grassTask(name)
+        if name in globalvar.grassCmd['all']:
+            task = menuform.grassTask(name)
+        else:
+            task = menuform.grassTask()
         task.flags  = params['flags']
         task.params = params['params']
         

Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py	2010-06-10 06:56:53 UTC (rev 42540)
+++ grass/trunk/gui/wxpython/icons/icon.py	2010-06-10 10:27:07 UTC (rev 42541)
@@ -362,9 +362,9 @@
     "modelRelation" : MetaIcon (img=Icons["modelRelation"],
                                 label=_("Define relation between data and action items")),
     "modelRun" : MetaIcon (img=Icons["modelRun"],
-                           label=_("Run entire model")),
+                           label=_("Run model")),
     "modelValidate" : MetaIcon (img=Icons["modelValidate"],
-                                label=_("Validate entire model")),
+                                label=_("Validate model")),
     "modelSettings" : MetaIcon (img=Icons["settings"],
                                 label=_("Show modeler settings")),
     "modelProperties" : MetaIcon (img=Icons["modelProperties"],



More information about the grass-commit mailing list