[GRASS-SVN] r49002 - in grass/branches/develbranch_6/gui/wxpython: gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 29 18:14:49 EDT 2011


Author: martinl
Date: 2011-10-29 15:14:49 -0700 (Sat, 29 Oct 2011)
New Revision: 49002

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menudata.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: implement customizable id for menu items
       (merge r49001 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py	2011-10-29 22:13:28 UTC (rev 49001)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py	2011-10-29 22:14:49 UTC (rev 49002)
@@ -56,7 +56,7 @@
         return menu
 
     def _createMenuItem(self, menu, menustyle, label, help, handler, gcmd, keywords,
-                        shortcut = '', kind = wx.ITEM_NORMAL):
+                        shortcut = '', wxId = wx.ID_ANY, kind = wx.ITEM_NORMAL):
         """!Creates menu items
         There are three menu styles (menu item text styles).
         1 -- label only, 2 -- label and cmd name, 3 -- cmd name only
@@ -77,7 +77,7 @@
         if shortcut:
             label += '\t' + shortcut
         
-        menuItem = menu.Append(wx.ID_ANY, label, helpString, kind)
+        menuItem = menu.Append(wxId, label, helpString, kind)
         
         self.menucmd[menuItem.GetId()] = gcmd
         

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menudata.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menudata.py	2011-10-29 22:13:28 UTC (rev 49001)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menudata.py	2011-10-29 22:14:49 UTC (rev 49002)
@@ -38,6 +38,8 @@
 except ImportError:
     import elementtree.ElementTree as etree # Python <= 2.4
 
+import wx
+
 if not os.getenv("GISBASE"):
     sys.exit("GRASS is not running. Exiting...")
 
@@ -62,6 +64,7 @@
 	    gcmd     = mi.find('command')  # optional
             keywords = mi.find('keywords') # optional
             shortcut = mi.find('shortcut') # optional
+            wxId     = mi.find('id')       # optional
 	    if gcmd != None:
 		gcmd = gcmd.text
 	    else:
@@ -74,7 +77,11 @@
                 shortcut = shortcut.text
             else:
                 shortcut = ""
-	    return (label, help, handler, gcmd, keywords, shortcut)
+            if wxId != None:
+                wxId = eval('wx.' + wxId.text)
+            else:
+                wxId = wx.ID_ANY
+	    return (label, help, handler, gcmd, keywords, shortcut, wxId)
 	elif mi.tag == 'menu':
 	    return self._getMenu(mi)
 	else:

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-10-29 22:13:28 UTC (rev 49001)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-10-29 22:14:49 UTC (rev 49002)
@@ -11,28 +11,33 @@
 	      <help>Create new workspace</help>
 	      <handler>OnWorkspaceNew</handler>
 	      <shortcut>Ctrl+N</shortcut>
+	      <id>ID_NEW</id>
 	    </menuitem>
 	    <menuitem>
 	      <label>Open</label>
 	      <help>Load workspace from file</help>
 	      <handler>OnWorkspaceOpen</handler>
 	      <shortcut>Ctrl+O</shortcut>
+	      <id>ID_OPEN</id>
 	    </menuitem>
 	    <menuitem>
 	      <label>Save</label>
 	      <help>Save workspace</help>
 	      <handler>OnWorkspaceSave</handler>
 	      <shortcut>Ctrl+S</shortcut>
+	      <id>ID_SAVE</id>
 	    </menuitem>
 	    <menuitem>
 	      <label>Save as</label>
 	      <help>Save workspace to file</help>
 	      <handler>OnWorkspaceSaveAs</handler>
+	      <id>ID_SAVEAS</id>
 	    </menuitem>
 	    <menuitem>
 	      <label>Close</label>
 	      <help>Close workspace file</help>
 	      <handler>OnWorkspaceClose</handler>
+	      <id>ID_CLOSE</id>
 	    </menuitem>
 	    <separator />
 	    <menuitem>
@@ -706,6 +711,7 @@
 	  <help>Quit wxGUI session</help>
 	  <handler>OnCloseWindow</handler>
 	  <shortcut>Ctrl+Q</shortcut>
+	  <id>ID_EXIT</id>
 	</menuitem>
       </items>
     </menu>
@@ -860,6 +866,7 @@
 	  <label>Preferences</label>
 	  <help>User GUI preferences (display font, commands, digitizer, etc.)</help>
 	  <handler>OnPreferences</handler>
+	  <id>ID_PREFERENCES</id>
 	</menuitem>
       </items>
     </menu>
@@ -3010,6 +3017,7 @@
 	  <keywords>general,manual,help</keywords>
 	  <handler>RunMenuCmd</handler>
 	  <command>g.manual -i</command>
+	  <id>ID_HELP</id>
 	</menuitem>
 	<menuitem>
 	  <label>GUI help</label>
@@ -3017,12 +3025,14 @@
 	  <keywords>general,manual,help</keywords>
 	  <handler>RunMenuCmd</handler>
 	  <command>g.manual entry=wxGUI</command>
+	  <id>ID_HELP</id>
 	</menuitem>
 	<separator />
 	<menuitem>
 	  <label>About GRASS GIS</label>
 	  <help>About GRASS GIS</help>
 	  <handler>OnAboutGRASS</handler>
+	  <id>ID_ABOUT</id>
 	</menuitem>
       </items>
     </menu>



More information about the grass-commit mailing list