20 from ..widgets
import ImageProvider
21 from .shortcut
import Shortcut
110 for row
in data.splitlines():
114 elif row.startswith(
'[')
and row.endswith(
']'):
115 menu = row[1:-1].strip()
122 if row.startswith(
'---'):
124 tokens = [t.strip()
for t
in row.split(
'|')]
125 tokens += [
''] * (5-len(tokens))
126 name, doc, shortcut, icon, position = tokens
127 if name.startswith(
'!'):
131 action = getattr(eventhandler, eventhandler_name)
132 return ActionInfo(menu, name, action, container, shortcut, icon, doc, position)
137 return 'On%s' % eventhandler_name.replace(
' ',
'').replace(
'&',
''), name
142 eventhandler_name, shortcuts = name.split(
'(', 1)
143 shortcuts = shortcuts.split(
')')[0]
144 elements = shortcuts.split(
' or ')
145 name =
'%s (%s)' % (eventhandler_name,
' or '.join(
Shortcut(e).printable
for e
in
147 return eventhandler_name, name
219 def __init__(self, menu_name, name, action=None, container=None,
220 shortcut=None, icon=None, doc='', position=-1):
221 MenuInfo.__init__(self)
236 if not self.
_icon_icon:
238 return self.
_icon_icon
245 return ImageProvider().get_image_by_name(self.
_icon_source_icon_source[len(
"CUSTOM_"):])
246 return wx.ArtProvider.GetBitmap(getattr(wx, self.
_icon_source_icon_source),
247 wx.ART_TOOLBAR, (16, 16))
254 if isinstance(self.
_position_position, int):
256 elif isinstance(self.
_position_position, str):
258 return int(self.
_position_position.split(
"POSITION-")[-1])
272 MenuInfo.__init__(self)
283 _shortcut_remover = re.compile(
' {2,}\([^()]+\)$')
290 if not self.
_item_item:
291 return menu.GetMenuItemCount()
294 return menu.GetMenuItemCount()
300 for index
in range(0, menu.GetMenuItemCount()):
301 item = menu.FindItemByPosition(index)
307 if wx.VERSION < (4, 1, 0):
Used to create menu entries, keyboard shortcuts and/or toolbar buttons.
def __init__(self, menu_name, name, action=None, container=None, shortcut=None, icon=None, doc='', position=-1)
Initializes information needed to create actions.
Used to create separators to menus.
def __init__(self, menu_name)
Initializes information needed to add separators to menus.
def _find_position_in_menu(self, menu)
def _get_menu_item_name(self, item)
def get_index(self, menu)
def __init__(self, before=None, after=None)
def ActionInfoCollection(data, event_handler, container=None)
Parses the data into a list of ActionInfo and SeparatorInfo objects.
def _parse_shortcuts_from_name(name)
def _create_action_info(eventhandler, menu, container, row)
def _get_eventhandler_name_and_parsed_name(name)