From 9bbbe89b36f42d06f7485b58057ef994322a8d9e Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 20 Jan 2015 13:44:35 +0100 Subject: [PATCH] add recent events to file menu --- QtPyLoT.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 9176326a..f0f7f934 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -113,15 +113,21 @@ class MainWindow(QMainWindow): def updateFileMenu(self): self.fileMenu.clear() - self.addActions(self.fileMenu, self.fileMenuActions[:-1]) - current = self.data.evtdata.getID() + for action in self.fileMenuActions[:-1]: + if action is None: + self.fileMenu.addSeparator() + else: + self.fileMenu.addAction(action) + try: + current = self.data.evtdata.getID() + except AttributeError: + current = None recentEvents = [] for eventID in self.recentEvents: fname = fnConstructor(eventID) if eventID != current and QFile.exists(fname): recentEvents.append(eventID) if recentEvents: - self.fileMenu.addSeparator() for i, eventID in enumerate(recentEvents): fname = fnConstructor(eventID) action = QAction(QIcon(":/icon.png"), @@ -231,7 +237,10 @@ class MainWindow(QMainWindow): self.fileMenuActions = (openEventAction, saveEventAction, None, prefsEventAction, None, quitAction) + self.fileMenuActions = (openEventAction, saveEventAction, + prefsEventAction, quitAction) self.fileMenu.aboutToShow.connect(self.updateFileMenu) + self.updateFileMenu() self.editMenu = self.menuBar().addMenu('&Edit') for action in (filterAction, filterEditAction, None, selectPAction,