import asyncio import tkinter as tk from tkinter import ttk from async_tkinter_loop import async_handler, async_mainloop from networking import send_to_server import color_utils class App: def __init__(self) -> None: self.root = tk.Tk() self.root.attributes('-fullscreen', True) # Red Slider self.red_slider = tk.Scale(self.root, from_=255, to=0, orient=tk.VERTICAL, length=500, width=50, label="Red") self.red_slider.set(0) self.red_slider.pack(side=tk.LEFT, padx=10) self.red_slider.bind("", self.update_colour) self.green_slider = tk.Scale(self.root, from_=255, to=0, orient=tk.VERTICAL, length=500, width=50, label="Green") self.green_slider.set(0) self.green_slider.pack(side=tk.LEFT, padx=10) self.green_slider.bind("", self.update_colour) self.blue_slider = tk.Scale(self.root, from_=255, to=0, orient=tk.VERTICAL, length=500, width=50, label="Blue") self.blue_slider.set(0) self.blue_slider.pack(side=tk.LEFT, padx=10) self.blue_slider.bind("", self.update_colour) self.brightness_slider = tk.Scale(self.root, from_=255, to=0, orient=tk.VERTICAL, length=500, width=50, label="Brighness") self.brightness_slider.set(127) self.brightness_slider.pack(side=tk.LEFT, padx=10) self.brightness_slider.bind("", self.update_colour) async_mainloop(self.root) @async_handler async def update_colour(self, event): print(event) r = self.red_slider.get() g = self.green_slider.get() b = self.blue_slider.get() brightness = self.brightness_slider.get() color = color_utils.adjust_brightness((r,b,g), brightness) print(color, brightness) await send_to_server(bytes(color), ("192.168.0.206","80")) if __name__ == "__main__": app = App()