forked from Backbone-Labs/uart_serial_plotter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenubar.py
30 lines (24 loc) · 1010 Bytes
/
menubar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def menubar_init(self):
self.menus = {}
self.menubar = self.menuBar()
def menubar_add_menu(self, menu_name):
"""
:param in string menu_name: name of the menu, shortcut (denoted by &) optional (note that the & will be stripped)
"""
dict_name = menu_name.strip("&")
if dict_name not in self.menus:
self.menus[dict_name] = self.menubar.addMenu(menu_name)
def menubar_get_menu(self, menu_name):
"""
:param in string menu_name: name of the menu, shortcut (denoted by &) optional (note that the & will be stripped)
"""
dict_name = menu_name.strip("&")
return self.menus[dict_name]
def menu_add_action(self, menu_name, menu_action):
"""
:param in string menu_name: name used to create the menu from :func:`Editor.menubar_add_menu`.
:param in Action menu_action: :class:`action.Action` object to bind to the menu.
"""
dict_name = menu_name.strip("&")
if dict_name in self.menus:
self.menus[dict_name].addAction(menu_action)