-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (44 loc) · 1.47 KB
/
main.py
File metadata and controls
59 lines (44 loc) · 1.47 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
59
# main.py
import tkinter as tk
import sys
import os
try:
import psutil
except ImportError:
print("ERROR: psutil is not installed. Install it with: pip install psutil")
sys.exit(1)
try:
import matplotlib
import matplotlib.pyplot as plt
except ImportError:
print("ERROR: matplotlib is not installed. Install it with: pip install matplotlib")
sys.exit(1)
from system_stats import SystemStats
from ui import SystemMonitorUI
from charts import ChartManager
from constants import UPDATE_INTERVAL
def main():
root = tk.Tk()
# Set application icon - absolute path for PyInstaller
if getattr(sys, 'frozen', False):
# Running as a bundled executable with PyInstaller
icon_path = os.path.join(sys._MEIPASS, 'SystemMonitorLogo.ico')
else:
# Running in development mode from source
icon_path = os.path.join(os.path.dirname(__file__), 'SystemMonitorLogo.ico')
if os.path.exists(icon_path):
root.iconbitmap(icon_path)
root.title('System Monitor')
stats_manager = SystemStats()
chart_manager = ChartManager(theme='dark')
ui = SystemMonitorUI(root, stats_manager, chart_manager)
def update_loop():
try:
ui.update_display()
except Exception as e:
print(f"Update error: {e}")
root.after(UPDATE_INTERVAL, update_loop)
root.after(UPDATE_INTERVAL, update_loop)
root.mainloop()
if __name__ == "__main__":
main()