-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (55 loc) · 2 KB
/
Copy pathmain.py
File metadata and controls
70 lines (55 loc) · 2 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
"""Launcher for SecureVoiceSystem GUIs.
Runs three independent GUI windows:
- Sender: records and sends audio (encrypted or raw)
- Middleman: intercepts, optionally modifies, and forwards
- Receiver: receives and plays (decrypts if needed)
Uses a single mainloop with update() calls.
"""
import customtkinter as ctk
import sys
from gui.sender_gui import SenderGUI
from gui.middleman_gui import MiddlemanGUI
from gui.receiver_gui import ReceiverGUI
def main():
"""Launch all three GUIs using a single event loop."""
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
print("[MAIN] Starting SecureVoiceSystem...")
print("[MAIN] Launching Sender, Middleman, and Receiver GUIs")
# Create GUI instances
try:
sender = SenderGUI()
middleman = MiddlemanGUI()
receiver = ReceiverGUI()
except Exception as e:
print(f"[ERROR] Failed to create GUIs: {e}")
return
# Position windows side-by-side
sender.geometry("+50+50")
middleman.geometry("+600+50")
receiver.geometry("+1150+50")
print("[MAIN] GUIs created successfully")
print("[MAIN] Use Sender → Send to trigger Middleman and Receiver updates")
# Import for event processing
from logic import network_utils
# Single event loop managing all windows
while True:
try:
sender.update()
# Process middleman events
network_utils.process_middleman_events(middleman._handle_packet_intercepted)
middleman.update()
# Process receiver events
network_utils.process_receiver_events(receiver)
receiver.update()
except Exception as e:
print(f"[MAIN] Event loop error: {e}")
break
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n[MAIN] Interrupted by user")
except Exception as e:
print(f"[MAIN] Fatal error: {e}")
sys.exit(1)