31 from python_qt_binding.QtCore
import QObject
32 from python_qt_binding.QtWidgets
import QAction, QMenu
36 """Menu manager containing alphabetically ordered items and other items before and after."""
40 self.setObjectName(
'MenuManager')
48 for action
in menu.actions():
58 if isinstance(before, QMenu):
59 before = before.menuAction()
83 return self.
get_item(name)
is not None
86 if isinstance(name, QAction)
or isinstance(name, QMenu):
96 return self.
get_menu(name)
is not None
113 item.setChecked(flag)
118 item.setDisabled(flag)
123 self.
menu.removeAction(item)
128 if isinstance(before, QMenu):
129 before = before.menuAction()
130 if isinstance(item, QAction):
131 self.
menu.insertAction(before, item)
132 elif isinstance(item, QMenu):
133 self.
menu.insertMenu(before, item)
135 self.
menu.insertSeparator(before)
137 raise UserWarning(
'unknown item type')
140 if isinstance(item, QAction):
142 elif isinstance(item, QMenu):
145 raise UserWarning(
'unknown item type')