[GRASS-SVN] r44778 - in grass/trunk/gui/wxpython: gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 29 15:16:50 EST 2010


Author: martinl
Date: 2010-12-29 12:16:50 -0800 (Wed, 29 Dec 2010)
New Revision: 44778

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: define first parameter for grassTask


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-12-29 19:58:09 UTC (rev 44777)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-12-29 20:16:50 UTC (rev 44778)
@@ -392,6 +392,7 @@
         self.flags = list()
         self.keywords = list()
         self.errorMsg = ''
+        self.firstParam = None
         
         if grassModule is not None:
             try:
@@ -399,7 +400,14 @@
                             task = self)
             except gcmd.GException, e:
                 self.errorMsg = str(e)
+                
+            self.define_first()
         
+    def define_first(self):
+        """!Define first parameter"""
+        if len(self.params) > 0:
+            self.firstParam = self.params[0]['name']
+        
     def get_error_msg(self):
         """!Get error message ('' for no error)"""
         return self.errorMsg
@@ -450,9 +458,8 @@
             return None
 
     def set_param(self, aParam, aValue, element = 'value'):
+        """!Set param value/values.
         """
-        Set param value/values.
-        """
         try:
             param = self.get_param(aParam)
         except ValueError:
@@ -461,18 +468,16 @@
         param[element] = aValue
             
     def get_flag(self, aFlag):
+        """!Find and return a flag by name.
         """
-        Find and return a flag by name.
-        """
         for f in self.flags:
             if f['name'] ==  aFlag:
                 return f
         raise ValueError, _("Flag not found: %s") % aFlag
 
     def set_flag(self, aFlag, aValue, element = 'value'):
+        """!Enable / disable flag.
         """
-        Enable / disable flag.
-        """
         try:
             param = self.get_flag(aFlag)
         except ValueError:
@@ -578,7 +583,8 @@
         self.__processModule()
         self.__processParams()
         self.__processFlags()
-
+        self.task.define_first()
+        
     def __processModule(self):
         """!Process module description"""
         self.task.name = self.root.get('name', default = 'unknown')
@@ -2232,11 +2238,11 @@
                     try:
                         key, value = option.split('=', 1)
                     except:
-                        if i ==  0: # add key name of first parameter if not given
+                        if i == 0: # add key name of first parameter if not given
                             key = self.grass_task.firstParam
                             value = option
                         else:
-                            raise gcmd.GException, _("Unable to parse command %s") % ' '.join(cmd)
+                            raise gcmd.GException, _("Unable to parse command '%s'") % ' '.join(cmd)
                     
                     element = self.grass_task.get_param(key, raiseError = False)
                     if not element:

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2010-12-29 19:58:09 UTC (rev 44777)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2010-12-29 20:16:50 UTC (rev 44778)
@@ -3088,7 +3088,7 @@
 	  <help>Display the HTML man pages of GRASS GIS</help>
 	  <keywords>general,manual,help</keywords>
 	  <handler>RunMenuCmd</handler>
-	  <command>g.manual wxGUI</command>
+	  <command>g.manual entry=wxGUI</command>
 	</menuitem>
 	<separator />
 	<menuitem>



More information about the grass-commit mailing list