How to make fake led light in tkinter Python

PHOTO EMBED

Wed Aug 14 2024 13:55:13 GMT+0000 (Coordinated Universal Time)

Saved by @freepythoncode ##python #coding #python #programming #tkinter

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()
content_copyCOPY