import tkinter as tk from PIL import Image, ImageTk import os import time from threading import Thread import inotify.adapters class YikingInterface: def __init__(self, root): self.root = root self.root.title("Yiking") self.root.configure(bg="black") # Canvas for displaying images self.canvas = tk.Canvas(self.root, bg="black", width=1024, height=768, highlightthickness=0, bd=0) self.canvas.pack(fill="both", expand=True) self.image_path = "/tmp/yiking.png" # Load initial image if it exists self.load_and_display_image() # Start file watcher in a separate thread self.start_file_watcher() def load_and_display_image(self): """Load and display the image on the canvas, rescaling if necessary.""" if os.path.exists(self.image_path): img = Image.open(self.image_path) img = img.resize((1024, 768), Image.Resampling.LANCZOS) self.tk_image = ImageTk.PhotoImage(img) self.canvas.create_image(0, 0, anchor="nw", image=self.tk_image) def start_file_watcher(self): """Start a file watcher to monitor changes on the image file.""" def watch_file(): notifier = inotify.adapters.Inotify() notifier.add_watch("/tmp") for event in notifier.event_gen(yield_nones=False): (_, type_names, path, filename) = event if filename == "yiking.png" and "IN_CLOSE_WRITE" in type_names: print(f"File updated: {os.path.join(path, filename)}") self.load_and_display_image() watcher_thread = Thread(target=watch_file, daemon=True) watcher_thread.start() if __name__ == "__main__": root = tk.Tk() app = YikingInterface(root) root.mainloop()