Skip to content

Commit

Permalink
About: Some return types, indent, and actually DO crash on unhandled …
Browse files Browse the repository at this point in the history
…errors
  • Loading branch information
C0rn3j committed Sep 28, 2024
1 parent 221aa5b commit 8136ec0
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions scc/gui/aboutdialog.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8136ec0

Please sign in to comment.