-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.pyw
More file actions
48 lines (40 loc) · 1.27 KB
/
GUI.pyw
File metadata and controls
48 lines (40 loc) · 1.27 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
import sys
import subprocess
import importlib
Required_Modules = ["psutil"]
def Install_If_Missing(Modules):
Failed = []
for Mod in Modules:
try:
importlib.import_module(Mod)
except ImportError:
try:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", Mod, "-q"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
importlib.import_module(Mod)
except Exception as E:
Failed.append((Mod, str(E)))
return Failed
Failed_Modules = Install_If_Missing(Required_Modules)
if Failed_Modules:
import tkinter as tk
from tkinter import messagebox
Root = tk.Tk()
Root.withdraw()
Msg = "[ ERROR ] Failed To Install Required Modules:\n\n"
for Mod, Err in Failed_Modules:
Msg += f" >> {Mod}: {Err}\n"
Msg += "\n[ FIX ] Run Manually:\n pip install " + " ".join(m for m, _ in Failed_Modules)
messagebox.showerror("MODULE INSTALL FAILED", Msg)
Root.destroy()
sys.exit(1)
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from Files.PY.App import Main_App
if __name__ == "__main__":
App = Main_App()
App.mainloop()