4 @brief Menu classes for wxGUI
9 (C) 2010 by the GRASS Development Team
10 This program is free software under the GNU General Public License
11 (>=v2). Read the file COPYING that comes with GRASS for details.
13 @author Martin Landa <landa.martin gmail.com>
14 @author Pawel Netzel (menu customization)
15 @author Milena Nowotarska (menu customization)
16 @author Robert Szczepanek (menu customization)
17 @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
25 from preferences
import globalSettings
as UserSettings
29 """!Creates menubar"""
30 wx.MenuBar.__init__(self)
35 self.
menustyle = UserSettings.Get(group=
'appearance', key=
'menustyle', subkey=
'selection')
37 for eachMenuData
in self.menudata.GetMenu():
38 for eachHeading
in eachMenuData:
39 menuLabel = eachHeading[0]
40 menuItems = eachHeading[1]
43 def _createMenu(self, menuData):
46 for eachItem
in menuData:
47 if len(eachItem) == 2:
50 menu.AppendMenu(wx.ID_ANY, label, subMenu)
58 def _createMenuItem(self, menu, menustyle, label, help, handler, gcmd, keywords,
59 shortcut =
'', kind = wx.ITEM_NORMAL):
60 """!Creates menu items
61 There are three menu styles (menu item text styles).
62 1 -- label only, 2 -- label and cmd name, 3 -- cmd name only
65 menu.AppendSeparator()
69 helpString = gcmd +
' -- ' + help
71 label +=
' [' + gcmd +
']'
73 label =
' [' + gcmd +
']'
78 label +=
'\t' + shortcut
80 menuItem = menu.Append(wx.ID_ANY, label, helpString, kind)
82 self.
menucmd[menuItem.GetId()] = gcmd
86 cmd = utils.split(str(gcmd))
88 cmd = utils.split(utils.EncodeString((gcmd)))
89 if cmd
and cmd[0]
not in globalvar.grassCmd[
'all']:
90 menuItem.Enable(
False)
92 rhandler = eval(
'self.parent.' + handler)
94 self.parent.Bind(wx.EVT_MENU, rhandler, menuItem)
101 """!Get list of commands
103 @return list of commands
109 Default menu help handler
112 id = event.GetMenuId()
113 item = self.FindItemById(id)
115 text = item.GetText()
116 help = item.GetHelp()