diff --git a/activity_browser/ui/menu_bar.py b/activity_browser/ui/menu_bar.py
index 0fd9c67b4..910a9636f 100644
--- a/activity_browser/ui/menu_bar.py
+++ b/activity_browser/ui/menu_bar.py
@@ -1,11 +1,12 @@
import os
+from importlib.metadata import version
+
from PySide2 import QtGui, QtWidgets
from PySide2.QtCore import QSize, QUrl, Slot
-from activity_browser import actions, signals
+from activity_browser import actions, signals, application, info
from activity_browser.mod import bw2data as bd
-from ..info import __version__ as ab_version
from .icons import qicons
AB_BW25 = True if os.environ.get("AB_BW25", False) else False
@@ -14,57 +15,11 @@
class MenuBar(QtWidgets.QMenuBar):
def __init__(self, window):
super().__init__(parent=window)
- self.help_menu = QtWidgets.QMenu("&Help", self)
self.addMenu(ProjectMenu(self))
self.addMenu(ViewMenu(self))
self.addMenu(ToolsMenu(self))
- self.addMenu(self.help_menu)
-
- self.setup_help_menu()
-
- def setup_help_menu(self) -> None:
- """Build the help menu for the menubar."""
- self.help_menu.addAction(
- self.window().icon, "&About Activity Browser", self.about
- )
- self.help_menu.addAction(
- "&About Qt", lambda: QtWidgets.QMessageBox.aboutQt(self.parent())
- )
- self.help_menu.addAction(
- qicons.question, "&Get help on the wiki", self.open_wiki
- )
- self.help_menu.addAction(
- qicons.issue, "&Report an idea/issue on GitHub", self.raise_issue_github
- )
-
- def about(self):
- text = """
-Activity Browser - a graphical interface for Brightway2.
-Application version: {}
-All development happens on github.
-For copyright information please see the copyright on this page.
-For license information please see the copyright on this page.
-"""
- msgBox = QtWidgets.QMessageBox(parent=self.parent())
- msgBox.setWindowTitle("About the Activity Browser")
- pixmap = self.parent().icon.pixmap(QSize(150, 150))
- msgBox.setIconPixmap(pixmap)
- msgBox.setWindowIcon(self.parent().icon)
- msgBox.setText(text.format(ab_version))
- msgBox.exec_()
-
- def open_wiki(self):
- url = QUrl(
- "https://github.com/LCA-ActivityBrowser/activity-browser/wiki"
- )
- QtGui.QDesktopServices.openUrl(url)
-
- def raise_issue_github(self):
- url = QUrl(
- "https://github.com/LCA-ActivityBrowser/activity-browser/issues/new/choose"
- )
- QtGui.QDesktopServices.openUrl(url)
+ self.addMenu(HelpMenu(self))
class ProjectMenu(QtWidgets.QMenu):
@@ -145,6 +100,56 @@ def __init__(self, parent=None) -> None:
self.addAction(self.manage_plugins_action)
+class HelpMenu(QtWidgets.QMenu):
+ def __init__(self, parent=None) -> None:
+ super().__init__(parent)
+ self.setTitle("&Help")
+
+ self.addAction(
+ qicons.ab, "&About Activity Browser", self.about
+ )
+ self.addAction(
+ "&About Qt", lambda: QtWidgets.QMessageBox.aboutQt(application.main_window)
+ )
+ self.addAction(
+ qicons.question, "&Get help on the wiki", self.open_wiki
+ )
+ self.addAction(
+ qicons.issue, "&Report an idea/issue on GitHub", self.raise_issue_github
+ )
+
+ def about(self):
+ text = f"""
+ Activity Browser - a graphical interface for Brightway2.
+ Application version: {version("activity_browser")}
+ bw2data version: {version("bw2data")}
+ bw2io version: {version("bw2calc")}
+ bw2calc version: {version("bw2io")}
+ All development happens on github.
+ For copyright information please see the copyright on this page.
+ For license information please see the copyright on this page.
+ """
+
+ about_window = QtWidgets.QMessageBox(parent=application.main_window)
+ about_window.setWindowTitle("About the Activity Browser")
+ about_window.setIconPixmap(qicons.ab.pixmap(QSize(150, 150)))
+ about_window.setText(text)
+
+ about_window.exec_()
+
+ def open_wiki(self):
+ url = QUrl(
+ "https://github.com/LCA-ActivityBrowser/activity-browser/wiki"
+ )
+ QtGui.QDesktopServices.openUrl(url)
+
+ def raise_issue_github(self):
+ url = QUrl(
+ "https://github.com/LCA-ActivityBrowser/activity-browser/issues/new/choose"
+ )
+ QtGui.QDesktopServices.openUrl(url)
+
+
class ProjectSelectionMenu(QtWidgets.QMenu):
"""
Menu that lists all the projects available through bw2data.projects