[GRASS-SVN] r42542 - in grass/branches/develbranch_6/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:34:06 +0000 (Thu, 10 Jun 2010)
New Revision: 42542

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/icons/icon.py
Log:
wxGUI/model: run model with variables 
(nerge r42541 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-06-10 10:27:07 UTC (rev 42541)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-06-10 10:34:06 UTC (rev 42542)
@@ -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/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2010-06-10 10:27:07 UTC (rev 42541)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2010-06-10 10:34:06 UTC (rev 42542)
@@ -360,9 +360,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