[GRASS-SVN] r58562 - in grass/trunk/gui/wxpython: core gui_core xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 30 09:36:10 PST 2013
Author: martinl
Date: 2013-12-30 09:36:10 -0800 (Mon, 30 Dec 2013)
New Revision: 58562
Modified:
grass/trunk/gui/wxpython/core/menutree.py
grass/trunk/gui/wxpython/gui_core/menu.py
grass/trunk/gui/wxpython/xml/menudata.README
grass/trunk/gui/wxpython/xml/wxgui_items.xml
Log:
wxGUI/menu: add icon tag
Modified: grass/trunk/gui/wxpython/core/menutree.py
===================================================================
--- grass/trunk/gui/wxpython/core/menutree.py 2013-12-30 12:51:39 UTC (rev 58561)
+++ grass/trunk/gui/wxpython/core/menutree.py 2013-12-30 17:36:10 UTC (rev 58562)
@@ -90,7 +90,7 @@
def _createItem(self, item, node):
if item.tag == 'separator':
data = dict(label='', description='', handler='',
- command='', keywords='', shortcut='', wxId='')
+ command='', keywords='', shortcut='', wxId='', icon='')
self.model.AppendNode(parent=node, label='', data=data)
elif item.tag == 'menuitem':
origLabel = _(item.find('label').text)
@@ -100,6 +100,7 @@
keywords = item.find('keywords') # optional
shortcut = item.find('shortcut') # optional
wxId = item.find('id') # optional
+ icon = item.find('icon') # optional
if gcmd != None:
gcmd = gcmd.text
else:
@@ -120,6 +121,10 @@
wxId = eval('wx.' + wxId.text)
else:
wxId = wx.ID_ANY
+ if icon != None:
+ icon = icon.text
+ else:
+ icon = ''
label = origLabel
if gcmd:
if self.menustyle == 1:
@@ -127,7 +132,7 @@
elif self.menustyle == 2:
label = ' [' + gcmd + ']'
data = dict(label=origLabel, description=desc, handler=handler,
- command=gcmd, keywords=keywords, shortcut=shortcut, wxId=wxId)
+ command=gcmd, keywords=keywords, shortcut=shortcut, wxId=wxId, icon=icon)
self.model.AppendNode(parent=node, label=label, data=data)
elif item.tag == 'menu':
self._createMenu(item, node)
Modified: grass/trunk/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/menu.py 2013-12-30 12:51:39 UTC (rev 58561)
+++ grass/trunk/gui/wxpython/gui_core/menu.py 2013-12-30 17:36:10 UTC (rev 58562)
@@ -7,7 +7,7 @@
- menu::Menu
- menu::SearchModuleWindow
-(C) 2010-2012 by the GRASS Development Team
+(C) 2010-2013 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -27,6 +27,7 @@
from core.utils import _
from gui_core.widgets import SearchModuleWidget
from gui_core.treeview import CTreeView
+from icons.icon import MetaIcon
from grass.pydispatch.signal import Signal
@@ -37,6 +38,7 @@
self.parent = parent
self.model = model
self.menucmd = dict()
+ self.bmpsize = (16, 16)
for child in self.model.root.children:
self.Append(self._createMenu(child), child.label)
@@ -52,6 +54,7 @@
else:
data = child.data.copy()
data.pop('label')
+
self._createMenuItem(menu, label=child.label, **data)
self.parent.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight)
@@ -59,7 +62,7 @@
return menu
def _createMenuItem(self, menu, label, description, handler, command, keywords,
- shortcut = '', wxId = wx.ID_ANY, kind = wx.ITEM_NORMAL):
+ shortcut = '', icon = '', 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
@@ -76,7 +79,10 @@
if shortcut:
label += '\t' + shortcut
- menuItem = menu.Append(wxId, label, helpString, kind)
+ menuItem = wx.MenuItem(menu, wxId, label, helpString, kind)
+ if icon:
+ menuItem.SetBitmap(MetaIcon(img = icon).GetBitmap(self.bmpsize))
+ menu.AppendItem(menuItem)
self.menucmd[menuItem.GetId()] = command
Modified: grass/trunk/gui/wxpython/xml/menudata.README
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.README 2013-12-30 12:51:39 UTC (rev 58561)
+++ grass/trunk/gui/wxpython/xml/menudata.README 2013-12-30 17:36:10 UTC (rev 58562)
@@ -27,4 +27,5 @@
the <command> module's module->keywords. [do not edit]
(G_add_keyword() in GRASS 7+)
+<icon> optional icon to be shown in the menu
Modified: grass/trunk/gui/wxpython/xml/wxgui_items.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/wxgui_items.xml 2013-12-30 12:51:39 UTC (rev 58561)
+++ grass/trunk/gui/wxpython/xml/wxgui_items.xml 2013-12-30 17:36:10 UTC (rev 58562)
@@ -13,6 +13,7 @@
<related-module>g.gui.gmodeler</related-module>
<description>Launch Graphical modeler</description>
<keywords>general,gui,graphical modeler,workflow</keywords>
+ <icon>modeler-main</icon>
</wxgui-item>
<wxgui-item name="RunModel">
<label>Run model</label>
More information about the grass-commit
mailing list