[GRASS-SVN] r49001 - in grass/trunk/gui/wxpython: gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Oct 29 18:13:28 EDT 2011
Author: martinl
Date: 2011-10-29 15:13:28 -0700 (Sat, 29 Oct 2011)
New Revision: 49001
Modified:
grass/trunk/gui/wxpython/gui_modules/menu.py
grass/trunk/gui/wxpython/gui_modules/menudata.py
grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: implement customizable id for menu items
Modified: grass/trunk/gui/wxpython/gui_modules/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menu.py 2011-10-29 22:00:27 UTC (rev 49000)
+++ grass/trunk/gui/wxpython/gui_modules/menu.py 2011-10-29 22:13:28 UTC (rev 49001)
@@ -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/trunk/gui/wxpython/gui_modules/menudata.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menudata.py 2011-10-29 22:00:27 UTC (rev 49000)
+++ grass/trunk/gui/wxpython/gui_modules/menudata.py 2011-10-29 22:13:28 UTC (rev 49001)
@@ -39,6 +39,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...")
@@ -63,6 +65,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:
@@ -75,7 +78,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/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml 2011-10-29 22:00:27 UTC (rev 49000)
+++ grass/trunk/gui/wxpython/xml/menudata.xml 2011-10-29 22:13:28 UTC (rev 49001)
@@ -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>
@@ -749,6 +754,7 @@
<help>Quit wxGUI session</help>
<handler>OnCloseWindow</handler>
<shortcut>Ctrl+Q</shortcut>
+ <id>ID_EXIT</id>
</menuitem>
</items>
</menu>
@@ -889,6 +895,7 @@
<label>Preferences</label>
<help>User GUI preferences (display font, commands, digitizer, etc.)</help>
<handler>OnPreferences</handler>
+ <id>ID_PREFERENCES</id>
</menuitem>
</items>
</menu>
@@ -3229,6 +3236,7 @@
<keywords>general,manual,help</keywords>
<handler>RunMenuCmd</handler>
<command>g.manual -i</command>
+ <id>ID_HELP</id>
</menuitem>
<menuitem>
<label>GUI help</label>
@@ -3236,12 +3244,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