-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_main.py
More file actions
489 lines (399 loc) · 19.9 KB
/
gui_main.py
File metadata and controls
489 lines (399 loc) · 19.9 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
#!/usr/bin/env python3
"""
🚀 Ultimate AI System Automation Agent - Modern Sci-Fi GUI 🚀
"""
import tkinter as tk
from tkinter import ttk, messagebox, scrolledtext
import threading
import time
import os
import sys
from datetime import datetime
import json
import subprocess
import shutil
class SciFiGUI:
"""Modern Sci-Fi GUI for the Ultimate AI System Automation Agent"""
def __init__(self):
self.root = tk.Tk()
self.root.title("🚀 Ultimate AI System Automation Agent")
self.root.geometry("1200x800")
self.root.configure(bg='#0a0a0a')
# Sci-Fi color scheme
self.colors = {
'bg': '#0a0a0a',
'primary': '#00ffff',
'secondary': '#ff00ff',
'accent': '#ffff00',
'text': '#ffffff',
'panel': '#1a1a1a',
'border': '#333333',
'success': '#00ff00',
'warning': '#ffaa00',
'error': '#ff0000'
}
# Configure style
self.setup_styles()
# Agent status
self.agent_running = False
self.tasks = {
"system_health_check": {
"name": "System Health Check",
"description": "Monitor system resources",
"enabled": True,
"status": "Ready"
},
"cleanup_temp_files": {
"name": "Cleanup Temporary Files",
"description": "Remove temporary files",
"enabled": True,
"status": "Ready"
}
}
# Create GUI
self.create_gui()
# Start monitoring thread
self.start_monitoring()
def setup_styles(self):
"""Setup custom styles for sci-fi theme"""
style = ttk.Style()
style.theme_use('clam')
# Configure styles
style.configure('SciFi.TFrame', background=self.colors['bg'])
style.configure('SciFi.TLabel',
background=self.colors['bg'],
foreground=self.colors['text'],
font=('Consolas', 10))
style.configure('SciFi.TButton',
background=self.colors['primary'],
foreground='#000000',
font=('Consolas', 10, 'bold'),
borderwidth=0)
style.map('SciFi.TButton',
background=[('active', self.colors['secondary'])])
style.configure('SciFi.TEntry',
fieldbackground=self.colors['panel'],
foreground=self.colors['text'],
borderwidth=1,
insertcolor=self.colors['primary'])
style.configure('SciFi.Treeview',
background=self.colors['panel'],
foreground=self.colors['text'],
fieldbackground=self.colors['panel'],
borderwidth=1)
style.configure('SciFi.Treeview.Heading',
background=self.colors['primary'],
foreground='#000000',
font=('Consolas', 10, 'bold'))
def create_gui(self):
"""Create the main GUI layout"""
# Main container
main_frame = ttk.Frame(self.root, style='SciFi.TFrame')
main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
# Header
self.create_header(main_frame)
# Main content area
content_frame = ttk.Frame(main_frame, style='SciFi.TFrame')
content_frame.pack(fill=tk.BOTH, expand=True, pady=(20, 0))
# Left panel - Controls
self.create_control_panel(content_frame)
# Right panel - Status and Logs
self.create_status_panel(content_frame)
# Bottom panel - System Info
self.create_system_panel(main_frame)
def create_header(self, parent):
"""Create the header section"""
header_frame = ttk.Frame(parent, style='SciFi.TFrame')
header_frame.pack(fill=tk.X, pady=(0, 10))
# Title
title_label = ttk.Label(header_frame,
text="🚀 ULTIMATE AI SYSTEM AUTOMATION AGENT 🚀",
style='SciFi.TLabel',
font=('Consolas', 16, 'bold'))
title_label.pack(side=tk.LEFT)
# Status indicator
self.status_label = ttk.Label(header_frame,
text="● OFFLINE",
style='SciFi.TLabel',
font=('Consolas', 12, 'bold'),
foreground=self.colors['error'])
self.status_label.pack(side=tk.RIGHT)
# Animated border
self.create_animated_border(header_frame)
def create_animated_border(self, parent):
"""Create animated border effect"""
border_canvas = tk.Canvas(parent, height=2, bg=self.colors['bg'], highlightthickness=0)
border_canvas.pack(fill=tk.X, pady=(5, 0))
def animate_border():
border_canvas.delete("all")
for i in range(0, 1200, 20):
color = self.colors['primary'] if (i // 20) % 2 == 0 else self.colors['secondary']
border_canvas.create_line(i, 0, i+10, 0, fill=color, width=2)
self.root.after(500, animate_border)
animate_border()
def create_control_panel(self, parent):
"""Create the control panel"""
control_frame = ttk.LabelFrame(parent, text="CONTROL PANEL", style='SciFi.TFrame')
control_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(0, 10))
# Agent controls
agent_frame = ttk.Frame(control_frame, style='SciFi.TFrame')
agent_frame.pack(fill=tk.X, pady=10)
ttk.Label(agent_frame, text="AGENT STATUS", style='SciFi.TLabel', font=('Consolas', 12, 'bold')).pack()
self.start_button = ttk.Button(agent_frame,
text="🚀 START AGENT",
style='SciFi.TButton',
command=self.start_agent)
self.start_button.pack(pady=5)
self.stop_button = ttk.Button(agent_frame,
text="🛑 STOP AGENT",
style='SciFi.TButton',
command=self.stop_agent,
state=tk.DISABLED)
self.stop_button.pack(pady=5)
# Task controls
task_frame = ttk.Frame(control_frame, style='SciFi.TFrame')
task_frame.pack(fill=tk.BOTH, expand=True, pady=10)
ttk.Label(task_frame, text="AUTOMATION TASKS", style='SciFi.TLabel', font=('Consolas', 12, 'bold')).pack()
# Task list
self.task_tree = ttk.Treeview(task_frame, style='SciFi.Treeview', columns=('Status',), show='tree headings')
self.task_tree.heading('#0', text='Task')
self.task_tree.heading('Status', text='Status')
self.task_tree.column('#0', width=200)
self.task_tree.column('Status', width=100)
self.task_tree.pack(fill=tk.BOTH, expand=True, pady=5)
# Populate tasks
for task_id, task in self.tasks.items():
self.task_tree.insert('', 'end', text=task['name'], values=(task['status'],))
# Task buttons
task_button_frame = ttk.Frame(task_frame, style='SciFi.TFrame')
task_button_frame.pack(fill=tk.X, pady=5)
ttk.Button(task_button_frame, text="▶️ RUN SELECTED", style='SciFi.TButton', command=self.run_selected_task).pack(side=tk.LEFT, padx=5)
ttk.Button(task_button_frame, text="🔄 REFRESH", style='SciFi.TButton', command=self.refresh_tasks).pack(side=tk.LEFT, padx=5)
ttk.Button(task_button_frame, text="⚙️ CONFIGURE", style='SciFi.TButton', command=self.configure_tasks).pack(side=tk.LEFT, padx=5)
def create_status_panel(self, parent):
"""Create the status panel"""
status_frame = ttk.LabelFrame(parent, text="STATUS & LOGS", style='SciFi.TFrame')
status_frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True)
# System status
system_frame = ttk.Frame(status_frame, style='SciFi.TFrame')
system_frame.pack(fill=tk.X, pady=10)
ttk.Label(system_frame, text="SYSTEM STATUS", style='SciFi.TLabel', font=('Consolas', 12, 'bold')).pack()
# Status indicators
self.cpu_label = ttk.Label(system_frame, text="CPU: --%", style='SciFi.TLabel')
self.cpu_label.pack(anchor=tk.W)
self.memory_label = ttk.Label(system_frame, text="Memory: --%", style='SciFi.TLabel')
self.memory_label.pack(anchor=tk.W)
self.disk_label = ttk.Label(system_frame, text="Disk: --%", style='SciFi.TLabel')
self.disk_label.pack(anchor=tk.W)
# Log area
log_frame = ttk.Frame(status_frame, style='SciFi.TFrame')
log_frame.pack(fill=tk.BOTH, expand=True, pady=10)
ttk.Label(log_frame, text="ACTIVITY LOG", style='SciFi.TLabel', font=('Consolas', 12, 'bold')).pack()
self.log_text = scrolledtext.ScrolledText(log_frame,
bg=self.colors['panel'],
fg=self.colors['text'],
font=('Consolas', 9),
height=15)
self.log_text.pack(fill=tk.BOTH, expand=True)
# Log controls
log_button_frame = ttk.Frame(log_frame, style='SciFi.TFrame')
log_button_frame.pack(fill=tk.X, pady=5)
ttk.Button(log_button_frame, text="🗑️ CLEAR LOG", style='SciFi.TButton', command=self.clear_log).pack(side=tk.LEFT, padx=5)
ttk.Button(log_button_frame, text="💾 SAVE LOG", style='SciFi.TButton', command=self.save_log).pack(side=tk.LEFT, padx=5)
def create_system_panel(self, parent):
"""Create the system information panel"""
system_frame = ttk.LabelFrame(parent, text="SYSTEM INFORMATION", style='SciFi.TFrame')
system_frame.pack(fill=tk.X, pady=(10, 0))
info_frame = ttk.Frame(system_frame, style='SciFi.TFrame')
info_frame.pack(fill=tk.X, pady=10)
# System info labels
self.platform_label = ttk.Label(info_frame, text=f"Platform: {os.name}", style='SciFi.TLabel')
self.platform_label.pack(side=tk.LEFT, padx=10)
self.python_label = ttk.Label(info_frame, text=f"Python: {sys.version.split()[0]}", style='SciFi.TLabel')
self.python_label.pack(side=tk.LEFT, padx=10)
self.time_label = ttk.Label(info_frame, text="", style='SciFi.TLabel')
self.time_label.pack(side=tk.RIGHT, padx=10)
# Update time
self.update_time()
def start_agent(self):
"""Start the automation agent"""
self.agent_running = True
self.start_button.config(state=tk.DISABLED)
self.stop_button.config(state=tk.NORMAL)
self.status_label.config(text="● ONLINE", foreground=self.colors['success'])
self.log_message("🚀 Agent started successfully!")
# Start background tasks
threading.Thread(target=self.background_tasks, daemon=True).start()
def stop_agent(self):
"""Stop the automation agent"""
self.agent_running = False
self.start_button.config(state=tk.NORMAL)
self.stop_button.config(state=tk.DISABLED)
self.status_label.config(text="● OFFLINE", foreground=self.colors['error'])
self.log_message("🛑 Agent stopped")
def background_tasks(self):
"""Background tasks that run while agent is active"""
while self.agent_running:
try:
# Update system status
self.update_system_status()
# Run scheduled tasks
self.run_scheduled_tasks()
time.sleep(5) # Update every 5 seconds
except Exception as e:
self.log_message(f"❌ Error in background tasks: {e}")
time.sleep(10)
def update_system_status(self):
"""Update system status indicators"""
try:
# Get disk usage
if os.name == 'nt': # Windows
total, used, free = shutil.disk_usage("C:")
disk_percent = (used / total) * 100
self.disk_label.config(text=f"Disk: {disk_percent:.1f}%")
# Color coding
if disk_percent > 90:
self.disk_label.config(foreground=self.colors['error'])
elif disk_percent > 80:
self.disk_label.config(foreground=self.colors['warning'])
else:
self.disk_label.config(foreground=self.colors['success'])
else: # Linux/Mac
total, used, free = shutil.disk_usage("/")
disk_percent = (used / total) * 100
self.disk_label.config(text=f"Disk: {disk_percent:.1f}%")
# Mock CPU and memory (in real implementation, use psutil)
self.cpu_label.config(text="CPU: 45.2%")
self.memory_label.config(text="Memory: 67.8%")
except Exception as e:
self.log_message(f"❌ Error updating system status: {e}")
def run_scheduled_tasks(self):
"""Run scheduled automation tasks"""
for task_id, task in self.tasks.items():
if task['enabled'] and task['status'] == 'Ready':
# Simple scheduling - run every 30 seconds for demo
if hasattr(self, f'last_run_{task_id}'):
if time.time() - getattr(self, f'last_run_{task_id}') > 30:
self.run_task(task_id)
else:
setattr(self, f'last_run_{task_id}', time.time())
def run_task(self, task_id):
"""Run a specific task"""
try:
task = self.tasks[task_id]
task['status'] = 'Running'
self.update_task_display()
self.log_message(f"▶️ Running task: {task['name']}")
if task_id == 'system_health_check':
self.system_health_check()
elif task_id == 'cleanup_temp_files':
self.cleanup_temp_files()
task['status'] = 'Completed'
setattr(self, f'last_run_{task_id}', time.time())
self.log_message(f"✅ Task completed: {task['name']}")
except Exception as e:
task['status'] = 'Error'
self.log_message(f"❌ Task failed: {task['name']} - {e}")
self.update_task_display()
def system_health_check(self):
"""Perform system health check"""
self.log_message("🔍 Performing system health check...")
time.sleep(1) # Simulate work
self.log_message("✅ System health check completed")
def cleanup_temp_files(self):
"""Clean up temporary files"""
self.log_message("🧹 Cleaning up temporary files...")
time.sleep(2) # Simulate work
self.log_message("✅ Cleanup completed")
def run_selected_task(self):
"""Run the selected task"""
selection = self.task_tree.selection()
if selection:
item = self.task_tree.item(selection[0])
task_name = item['text']
for task_id, task in self.tasks.items():
if task['name'] == task_name:
threading.Thread(target=self.run_task, args=(task_id,), daemon=True).start()
break
def refresh_tasks(self):
"""Refresh the task display"""
self.update_task_display()
self.log_message("🔄 Task list refreshed")
def update_task_display(self):
"""Update the task tree display"""
for item in self.task_tree.get_children():
self.task_tree.delete(item)
for task_id, task in self.tasks.items():
status_color = {
'Ready': self.colors['text'],
'Running': self.colors['warning'],
'Completed': self.colors['success'],
'Error': self.colors['error']
}.get(task['status'], self.colors['text'])
self.task_tree.insert('', 'end', text=task['name'], values=(task['status'],))
def configure_tasks(self):
"""Open task configuration dialog"""
messagebox.showinfo("Configuration", "Task configuration dialog would open here")
def log_message(self, message):
"""Add a message to the log"""
timestamp = datetime.now().strftime("%H:%M:%S")
log_entry = f"[{timestamp}] {message}\n"
self.log_text.insert(tk.END, log_entry)
self.log_text.see(tk.END)
# Color coding
if "❌" in message or "Error" in message:
self.log_text.tag_add("error", f"{self.log_text.index(tk.END)}-2c", tk.END)
elif "✅" in message or "completed" in message:
self.log_text.tag_add("success", f"{self.log_text.index(tk.END)}-2c", tk.END)
elif "🚀" in message or "started" in message:
self.log_text.tag_add("info", f"{self.log_text.index(tk.END)}-2c", tk.END)
# Configure tags
self.log_text.tag_config("error", foreground=self.colors['error'])
self.log_text.tag_config("success", foreground=self.colors['success'])
self.log_text.tag_config("info", foreground=self.colors['primary'])
def clear_log(self):
"""Clear the log"""
self.log_text.delete(1.0, tk.END)
self.log_message("🗑️ Log cleared")
def save_log(self):
"""Save the log to file"""
try:
filename = f"automation_log_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt"
with open(filename, 'w') as f:
f.write(self.log_text.get(1.0, tk.END))
self.log_message(f"💾 Log saved to {filename}")
except Exception as e:
self.log_message(f"❌ Error saving log: {e}")
def update_time(self):
"""Update the time display"""
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.time_label.config(text=current_time)
self.root.after(1000, self.update_time)
def start_monitoring(self):
"""Start the monitoring thread"""
threading.Thread(target=self.monitor_loop, daemon=True).start()
def monitor_loop(self):
"""Main monitoring loop"""
while True:
try:
if self.agent_running:
# Update system status
self.update_system_status()
time.sleep(5)
except Exception as e:
print(f"Monitoring error: {e}")
time.sleep(10)
def run(self):
"""Start the GUI"""
self.log_message("🚀 Ultimate AI System Automation Agent GUI Started")
self.log_message("💡 Click 'START AGENT' to begin automation")
self.root.mainloop()
def main():
"""Main entry point"""
try:
app = SciFiGUI()
app.run()
except Exception as e:
print(f"Error starting GUI: {e}")
if __name__ == "__main__":
main()