new method added in order to add actions and separators to the menu in the menubar more easily

This commit is contained in:
Sebastian Wehling-Benatelli 2015-01-20 13:48:19 +01:00
parent 9bbbe89b36
commit 0bfe2ccc3d

View File

@ -243,12 +243,13 @@ class MainWindow(QMainWindow):
self.updateFileMenu() self.updateFileMenu()
self.editMenu = self.menuBar().addMenu('&Edit') self.editMenu = self.menuBar().addMenu('&Edit')
for action in (filterAction, filterEditAction, None, selectPAction, editActions = (filterAction, filterEditAction, None, selectPAction,
selectSAction, None, printAction): selectSAction, None, printAction)
if action is None: self.addMenuActions(self.editMenu, editActions)
self.editMenu.addSeparator()
else: self.helpMenu = self.menuBar().addMenu('&Help')
self.editMenu.addAction(action) helpActions = (helpAction)
self.addMenuActions(self.helpMenu, helpActions)
self.eventLabel = QLabel() self.eventLabel = QLabel()
self.eventLabel.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken) self.eventLabel.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken)
@ -263,6 +264,13 @@ class MainWindow(QMainWindow):
_widget.setLayout(_layout) _widget.setLayout(_layout)
self.setCentralWidget(_widget) self.setCentralWidget(_widget)
def addMenuActions(self, menu, actions):
for action in (actions):
if action is None:
menu.addSeparator()
else:
menu.addAction(action)
def okToContinue(self): def okToContinue(self):
if self.dirty: if self.dirty:
return self.saveData() return self.saveData()