-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
58 lines (43 loc) · 1.48 KB
/
Copy pathapp.py
File metadata and controls
58 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""Linux Tech Helper prototype entry point."""
from __future__ import annotations
import sys
try:
import gi
gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
from gi.repository import Gio, Gtk
except ImportError as exc:
print("GTK/PyGObject is required to run Linux Tech Helper.", file=sys.stderr)
print(f"Import error: {exc}", file=sys.stderr)
sys.exit(1)
from lth.core.database import Database
from lth.gui.first_run_wizard import FirstRunWizard
from lth.gui.main_window import MainWindow
from lth.gui.theme import apply_theme
class LinuxTechHelperApp(Gtk.Application):
def __init__(self) -> None:
super().__init__(
application_id="local.linuxtechhelper.prototype",
flags=Gio.ApplicationFlags.FLAGS_NONE,
)
self.db = Database()
self.window = None
def do_activate(self) -> None:
apply_theme()
self.db.initialize()
if self.db.has_machine_profile():
self.window = MainWindow(self, self.db)
else:
self.window = FirstRunWizard(self, self.db, self.open_main_window)
self.window.present()
def open_main_window(self) -> None:
if self.window is not None:
self.window.destroy()
self.window = MainWindow(self, self.db)
self.window.present()
def main() -> int:
app = LinuxTechHelperApp()
return app.run(sys.argv)
if __name__ == "__main__":
raise SystemExit(main())