forked from Ryochan7/sc-controller
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
About: Some return types, indent, and actually DO crash on unhandled …
…errors
- Loading branch information
Showing
1 changed file
with
28 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |