diff --git a/scc/gui/aboutdialog.py b/scc/gui/aboutdialog.py index 5d3848db..cebc01fa 100644 --- a/scc/gui/aboutdialog.py +++ b/scc/gui/aboutdialog.py @@ -1,45 +1,51 @@ -#!/usr/bin/env python3 -""" -SC-Controller - About dialog -""" -from scc.tools import _ - -from gi.repository import Gtk +"""SC-Controller - About dialog.""" from scc.gui.editor import Editor -import os, sys + class AboutDialog(Editor): - """ Standard looking about dialog """ + """Standard looking about dialog.""" + GLADE = "about.glade" - def __init__(self, app): + def __init__(self, app) -> None: self.app = app self.setup_widgets() - def setup_widgets(self): + def setup_widgets(self) -> None: + """Setup widgets and get and set app version in the About. + + TODO - We can get a mismatch like this and version won't be set then, why?: + location: /usr/lib/python3.12/site-packages + scc.__file__: /home/user/sc-controller/scc/__init__.py + """ Editor.setup_widgets(self) - # Get app version app_ver = "(unknown version)" - try: - import pkg_resources, scc - if scc.__file__.startswith(pkg_resources.require("sccontroller")[0].location): - app_ver = "v" + pkg_resources.require("sccontroller")[0].version - except: - # pkg_resources is not available or __version__ file missing - # There is no reason to crash on this. - pass + import pkg_resources + + import scc + sccontroller_module = pkg_resources.require("sccontroller")[0] + if sccontroller_module.location is not None: + if scc.__file__.startswith(sccontroller_module.location): + app_ver = "v" + sccontroller_module.version + else: + print( + "Could not get version, locations possibly could not match.", + f"scc.__file__:{scc.__file__}", + f"sccontroller_module.location: {sccontroller_module.location}", + f"sccontroller_module.version: {sccontroller_module.version}", + f"sccontroller_module: {sccontroller_module}") # Display version in UI self.builder.get_object("lblVersion").set_label(app_ver) - def show(self, modal_for): + def show(self, modal_for) -> None: if modal_for: self.window.set_transient_for(modal_for) self.window.set_modal(True) self.window.show() - def on_dialog_response(self, *a): + def on_dialog_response(self, *a) -> None: self.close()