-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
54 lines (41 loc) · 1.11 KB
/
Copy pathgui.py
File metadata and controls
54 lines (41 loc) · 1.11 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
"""Entry point for the image-extension lock tool GUI.
Run: python gui.py
"""
import os
import sys
import ctypes
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from image_lock.gui.main_window import MainWindow
from image_lock.gui.tray import run_tray
def is_admin():
if os.name != "nt":
return True
try:
return bool(ctypes.windll.shell32.IsUserAnAdmin())
except Exception:
return False
def main():
app = MainWindow()
def show():
try:
app.deiconify()
app.lift()
app.focus_force()
except Exception:
pass
def hide_to_tray():
try:
app.withdraw()
except Exception:
pass
# close button hides to tray
app.protocol("WM_DELETE_WINDOW", hide_to_tray)
run_tray(show, on_quit=lambda: app.after(0, app.destroy))
app.mainloop()
if __name__ == "__main__":
if os.name == "nt" and not is_admin():
ctypes.windll.shell32.ShellExecuteW(
None, "runas", sys.executable, " ".join(sys.argv), None, 1
)
sys.exit(0)
main()