[GRASS-SVN] r44423 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 25 16:20:28 EST 2010


Author: martinl
Date: 2010-11-25 13:20:28 -0800 (Thu, 25 Nov 2010)
New Revision: 44423

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: required/multiple boolean variables


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-11-25 21:02:20 UTC (rev 44422)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-11-25 21:20:28 UTC (rev 44423)
@@ -488,7 +488,7 @@
                 return errorList
         
         for p in self.params:
-            if not p.get('value', '') and p.get('required', 'no') != 'no':
+            if not p.get('value', '') and p.get('required', False):
                 if not p.get('default', ''):
                     desc = p.get('label', '')
                     if not desc:
@@ -515,7 +515,7 @@
                 else:
                     cmd += [ '-' + flag['name'] ]
         for p in self.params:
-            if p.get('value','') == '' and p.get('required','no') != 'no':
+            if p.get('value','') == '' and p.get('required', False):
                 if p.get('default', '') != '':
                     cmd += [ '%s=%s' % ( p['name'], p['default'] ) ]
                 elif ignoreErrors is False:
@@ -549,7 +549,7 @@
     def has_required(self):
         """!Check if command has at least one required paramater"""
         for p in self.params:
-            if p.get('required', 'no') == 'yes':
+            if p.get('required', False):
                 return True
         
         return False
@@ -617,11 +617,20 @@
                 for ki in node_key_desc.findall('item'):
                     key_desc.append(ki.text)
             
+            if p.get('multiple', 'no') == 'yes':
+                multiple = True
+            else:
+                multiple = False
+            if p.get('required', 'no') == 'yes':
+                required = True
+            else:
+                required = False
+            
             self.task.params.append( {
                 "name"           : p.get('name'),
                 "type"           : p.get('type'),
-                "required"       : p.get('required'),
-                "multiple"       : p.get('multiple'),
+                "required"       : required,
+                "multiple"       : multiple,
                 "label"          : self._getNodeText(p, 'label'),
                 "description"    : self._getNodeText(p, 'description'),
                 'gisprompt'      : gisprompt,
@@ -1087,7 +1096,7 @@
         self.Bind(wx.EVT_SIZE, self.OnSize)
         
         for task in not_hidden:
-            if task.get( 'required','no' ) == 'yes':
+            if task.get( 'required', False):
                 # All required go into Main, even if they had defined another guisection
                 task['guisection'] = _( 'Required' )
             if task.get( 'guisection','' ) == '':
@@ -1228,14 +1237,14 @@
             txt = None
 
             # text style (required -> bold)
-            if p.get('required','no') == 'no':
+            if not p.get('required', False):
                 text_style = wx.FONTWEIGHT_NORMAL
             else:
                 text_style = wx.FONTWEIGHT_BOLD
 
             # title sizer (description, name, type)
             if (len(p.get('values', []) ) > 0) and \
-                    p.get('multiple', 'no') == 'yes' and \
+                    p.get('multiple', False) and \
                     p.get('gisprompt',False) == False and \
                     p.get('type', '') == 'string':
                 title_txt = wx.StaticBox (parent=which_panel, id=wx.ID_ANY)
@@ -1257,7 +1266,7 @@
             self.label_id.append(title_txt.GetId())
 
             # title expansion
-            if p.get('multiple','no') == 'yes' and len( p.get('values','') ) == 0:
+            if p.get('multiple', False) and len( p.get('values','') ) == 0:
                 title = _("[multiple]") + " " + title
                 if p.get('value','') ==  '' :
                     p['value'] = p.get('default','')
@@ -1266,7 +1275,7 @@
                 valuelist      = map(str, p.get('values',[]))
                 valuelist_desc = map(unicode, p.get('values_desc',[]))
 
-                if p.get('multiple', 'no') == 'yes' and \
+                if p.get('multiple', False) and \
                         p.get('gisprompt',False) == False and \
                         p.get('type', '') == 'string':
                     title_txt.SetLabel(" %s: (%s, %s) " % (title, p['name'], p['type']))
@@ -1310,7 +1319,7 @@
                                                           str(valuelist[0])))
                         
                         if p.get('type', '') == 'integer' and \
-                                p.get('multiple','no') == 'no':
+                                not p.get('multiple', False):
 
                             # for multiple integers use textctrl instead of spinsctrl
                             try:
@@ -1362,7 +1371,7 @@
                 and p.get('prompt','') != 'color'):
 
                 title_txt.SetLabel(title + ':' )
-                if p.get('multiple','yes') == 'yes' or \
+                if p.get('multiple', False) or \
                         p.get('type', 'string') == 'string' or \
                         len(p.get('key_desc', [])) > 1:
                     txt3 = wx.TextCtrl(parent=which_panel, value = p.get('default',''))
@@ -2413,7 +2422,7 @@
             },{
             "name" : "plain_color",
             "description" : "This is a plain color, and it is a compulsory parameter",
-            "required" : "yes",
+            "required" : False,
             "gisprompt" : True,
             "prompt" : "color"
             },{
@@ -2455,7 +2464,7 @@
             {
             "name" : "a",
             "description" : "Some flag, will appear in Main since it is required",
-            "required" : "yes"
+            "required" : True
             },{
             "name" : "b",
             "description" : "pre-filled flag, will appear in options since it is not required",



More information about the grass-commit mailing list