import customtkinter as ctk root = ctk.CTk() root.geometry('200x200') led_on = '#4cff66' led_off = '#1e3c22' led = ctk.CTkLabel(root, text='\t', width=50, bg_color=led_off) led.place(x = 80, y = 80) def off_on(): if led._bg_color == led_off: led.configure(bg_color = led_on) led.update() return if led._bg_color == led_on: led.configure(bg_color = led_off) led.update() return bt = ctk.CTkButton(root, text = 'OFF/ON', command=off_on, width=70) bt.place(x = 80, y = 150) root.mainloop()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter