Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
62 lines (50 loc) · 1.99 KB
/
Copy pathapp.py
File metadata and controls
62 lines (50 loc) · 1.99 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
import sys
import os
import threading
import tkinter as tk
from tkinter import PhotoImage
# Add the 'modules' folder to the Python path
sys.path.append(os.path.join(os.path.dirname(__file__), 'modules'))
from modules.EVA import EVA
from modules.FileManager import read_json_key
path_eva = 'files/eva.json' # File path for status
# GUI Function to update the status
def update_status_label():
try:
status = read_json_key(path_eva, 'status')
if status == 'listening':
window.title("Listening")
window.iconphoto(False, PhotoImage(file="interface/circle_green.png"))
elif status == 'recognizing':
window.title("Recognizing")
window.iconphoto(False, PhotoImage(file="interface/circle_yellow.png"))
elif status == 'processing':
window.title("Processing")
window.iconphoto(False, PhotoImage(file="interface/circle_blue.png"))
elif status == 'speaking':
window.title("Speaking")
window.iconphoto(False, PhotoImage(file="interface/circle_purple.png"))
else:
window.title("Terminated")
window.iconphoto(False, PhotoImage(file="interface/circle_red.png"))
except Exception as e:
print(f"Error reading status file: {e}")
# Schedule the function to update every 1 ms
window.after(1, update_status_label)
# Function to run EVA in the background
def run_eva_in_background():
EVA()
# Create the main window
window = tk.Tk()
window.title("EVA")
window.geometry("300x0")
# To prevent the window from being closed or disappearing when clicking outside
window.attributes("-topmost", True) # Keep the window on top
window.grab_set() # Make the window grab all events (focus, clicks, etc.)
# Start a thread to run the EVA function in the background
eva_thread = threading.Thread(target=run_eva_in_background, daemon=True)
eva_thread.start()
# Start the status update loop
update_status_label()
# Start the Tkinter event loop
window.mainloop()