4 @brief Menu classes for wxGUI
9 (C) 2010 by the GRASS Development Team
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
14 @author Martin Landa <landa.martin gmail.com>
15 @author Pawel Netzel (menu customization)
16 @author Milena Nowotarska (menu customization)
17 @author Robert Szczepanek (menu customization)
18 @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
23 from core
import globalvar
24 from core
import utils
30 """!Creates menubar"""
31 wx.MenuBar.__init__(self)
36 self.
menustyle = UserSettings.Get(group=
'appearance', key=
'menustyle', subkey=
'selection')
38 for eachMenuData
in self.menudata.GetMenu():
39 for eachHeading
in eachMenuData:
40 menuLabel = eachHeading[0]
41 menuItems = eachHeading[1]
44 def _createMenu(self, menuData):
47 for eachItem
in menuData:
48 if len(eachItem) == 2:
51 menu.AppendMenu(wx.ID_ANY, label, subMenu)
59 def _createMenuItem(self, menu, menustyle, label, help, handler, gcmd, keywords,
60 shortcut =
'', wxId = wx.ID_ANY, kind = wx.ITEM_NORMAL):
61 """!Creates menu items
62 There are three menu styles (menu item text styles).
63 1 -- label only, 2 -- label and cmd name, 3 -- cmd name only
66 menu.AppendSeparator()
70 helpString = gcmd +
' -- ' + help
72 label +=
' [' + gcmd +
']'
74 label =
' [' + gcmd +
']'
79 label +=
'\t' + shortcut
81 menuItem = menu.Append(wxId, label, helpString, kind)
83 self.
menucmd[menuItem.GetId()] = gcmd
90 if cmd
and cmd[0]
not in globalvar.grassCmd:
91 menuItem.Enable(
False)
93 rhandler = eval(
'self.parent.' + handler)
95 self.parent.Bind(wx.EVT_MENU, rhandler, menuItem)
102 """!Get list of commands
104 @return list of commands
110 Default menu help handler
113 id = event.GetMenuId()
114 item = self.FindItemById(id)
116 text = item.GetText()
117 help = item.GetHelp()
def EncodeString
Return encoded string using system locales.
def split
Platform spefic shlex.split.