ソースを参照

wxGUI/modeler: expand variables
(merge https://trac.osgeo.org/grass/changeset/48836 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48837 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 13 年 前
コミット
aa189871d9
1 ファイル変更24 行追加21 行削除
  1. 24 21
      gui/wxpython/gui_modules/gmodeler.py

+ 24 - 21
gui/wxpython/gui_modules/gmodeler.py

@@ -479,6 +479,11 @@ class Model(object):
             if err:
             if err:
                 GError(parent = self, message = unicode('\n'.join(err)))
                 GError(parent = self, message = unicode('\n'.join(err)))
                 return
                 return
+            
+            # get variable values
+            varValue = dict()
+            for var in params['variables']['params']:
+                varValue[var['name']] = var['value']
         
         
         log.cmdThread.SetId(-1)
         log.cmdThread.SetId(-1)
         for item in self.GetItems():
         for item in self.GetItems():
@@ -495,7 +500,12 @@ class Model(object):
                 for variable in variables:
                 for variable in variables:
                     pattern = re.compile('%' + variable)
                     pattern = re.compile('%' + variable)
                     if pattern.search(cond):
                     if pattern.search(cond):
-                        value = variables[variable].get('value', '')
+                        value = ''
+                        if variable in varValue:
+                            value = varValue[variable]
+                        if not value:
+                            value = variables[variable].get('value', '')
+                        
                         vtype = variables[variable].get('type', 'string')
                         vtype = variables[variable].get('type', 'string')
                         if vtype == 'string':
                         if vtype == 'string':
                             value = '"' + value + '"'
                             value = '"' + value + '"'
@@ -592,9 +602,9 @@ class Model(object):
         idx = 0
         idx = 0
         if self.variables:
         if self.variables:
             params = list()
             params = list()
-            result[_("Variables")] = { 'flags'  : list(),
-                                       'params' : params,
-                                       'idx' : idx }
+            result["variables"] = { 'flags'  : list(),
+                                    'params' : params,
+                                    'idx' : idx }
             for name, values in self.variables.iteritems():
             for name, values in self.variables.iteritems():
                 gtype = values.get('type', 'string')
                 gtype = values.get('type', 'string')
                 if gtype in ('raster', 'vector', 'mapset'):
                 if gtype in ('raster', 'vector', 'mapset'):
@@ -3656,18 +3666,8 @@ class ModelParamDialog(wx.Dialog):
         
         
         wx.Dialog.__init__(self, parent = parent, id = id, title = title, style = style, **kwargs)
         wx.Dialog.__init__(self, parent = parent, id = id, title = title, style = style, **kwargs)
         
         
-        if globalvar.hasAgw:
-            self.notebook = FN.FlatNotebook(self, id = wx.ID_ANY,
-                                            agwStyle = FN.FNB_FANCY_TABS |
-                                            FN.FNB_BOTTOM |
-                                            FN.FNB_NO_NAV_BUTTONS |
-                                            FN.FNB_NO_X_BUTTON)
-        else:
-            self.notebook = FN.FlatNotebook(self, id = wx.ID_ANY,
-                                            style = FN.FNB_FANCY_TABS |
-                                            FN.FNB_BOTTOM |
-                                            FN.FNB_NO_NAV_BUTTONS |
-                                            FN.FNB_NO_X_BUTTON)
+        self.notebook = menuform.GNotebook(parent = self, 
+                                           style = globalvar.FNPageDStyle)
         
         
         panel = self._createPages()
         panel = self._createPages()
         wx.CallAfter(self.notebook.SetSelection, 0)
         wx.CallAfter(self.notebook.SetSelection, 0)
@@ -3694,8 +3694,8 @@ class ModelParamDialog(wx.Dialog):
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         mainSizer.Add(item = self.notebook, proportion = 1,
         mainSizer.Add(item = self.notebook, proportion = 1,
                       flag = wx.EXPAND)
                       flag = wx.EXPAND)
-        mainSizer.Add(item=btnSizer, proportion=0,
-                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
+        mainSizer.Add(item = btnSizer, proportion = 0,
+                      flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
         
         
         self.SetSizer(mainSizer)
         self.SetSizer(mainSizer)
         mainSizer.Fit(self)
         mainSizer.Fit(self)
@@ -3708,8 +3708,9 @@ class ModelParamDialog(wx.Dialog):
         for name in nameOrdered:
         for name in nameOrdered:
             params = self.params[name]
             params = self.params[name]
             panel = self._createPage(name, params)
             panel = self._createPage(name, params)
-            
-            self.notebook.AddPage(panel, text = name)
+            if name == 'variables':
+                name = _('Variables')
+            self.notebook.AddPage(page = panel, text = name)
         
         
         return panel
         return panel
     
     
@@ -3931,7 +3932,9 @@ class VariableListCtrl(ModelListCtrl):
     def __init__(self, parent, columns, **kwargs):
     def __init__(self, parent, columns, **kwargs):
         """!List of model variables"""
         """!List of model variables"""
         ModelListCtrl.__init__(self, parent, columns, **kwargs)
         ModelListCtrl.__init__(self, parent, columns, **kwargs)
-        
+
+        self.SetColumnWidth(2, 200) # default value
+
     def GetListCtrl(self):
     def GetListCtrl(self):
         """!Used by ColumnSorterMixin"""
         """!Used by ColumnSorterMixin"""
         return self
         return self