-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (47 loc) · 1.47 KB
/
main.py
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
60
61
62
63
# main.py
import dearpygui.dearpygui as dpg
import tkinter as tk
from src.ui.monitor import AgentMonitoringSystem
from src.core.config import SystemConfig
def get_screen_size_percentage(percentage=0.80):
# Create a root window and hide it
root = tk.Tk()
root.withdraw()
# Get the screen width and height
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# Calculate the width and height based on the percentage
width = int(screen_width * percentage)
height = int(screen_height * percentage)
# Destroy the root window
root.destroy()
return width, height
def main():
# Create DPG context first
dpg.create_context()
try:
# Initialize system
config = SystemConfig()
monitor = AgentMonitoringSystem(config)
width, height = get_screen_size_percentage()
# Create viewport (moved from setup_ui)
dpg.create_viewport(
title="Agent Monitoring System",
width=width,
height=height
)
# Setup UI elements
monitor.setup_ui()
# Setup DPG
dpg.setup_dearpygui()
# Show the viewport
dpg.show_viewport()
# Start the main loop
monitor.run()
except Exception as e:
print(f"Error during startup: {str(e)}")
raise
finally:
dpg.destroy_context()
if __name__ == "__main__":
main()