use simpler QAction logic
This commit is contained in:
@ -8,19 +8,10 @@ class BarMenu(MenuBase):
|
||||
def __init__(self, bar, name):
|
||||
super().__init__()
|
||||
self.qmenu = qmenu = bar.addMenu(name)
|
||||
qmenu.triggered[QAction].connect(self.on_select)
|
||||
self.actions = {}
|
||||
|
||||
def on_select(self, p):
|
||||
txt = p.text()
|
||||
if txt in self.checkboxes: #TODO: allow checkboxes with callback?
|
||||
return
|
||||
func = self.actions[txt]
|
||||
func()
|
||||
|
||||
def addAction(self, name, func):
|
||||
self.qmenu.addAction(name)
|
||||
self.actions[name] = func
|
||||
action = QAction(name, triggered=func, parent=self.qmenu) # here, parent needs to be set
|
||||
self.qmenu.addAction(action)
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user