

# https://www.globalsino.com/ICs/page4853.html
# True/False Switch

from tkinter import *

root = Tk()
root.title('On/Off Switch')
root.geometry('500x350')

# Track the button state
global is_on
is_on = True

my_label = Label(root, text = "", fg="grey", font=("Helvetica", 30))
my_label.pack(pady=2)

# Define switch function
def Switch_func():
    global is_on
    # Determine is on or off
    if is_on:
        is_on = False
        my_label.config(text="False", fg='black')
        print(is_on)
    else:
        is_on = True
        my_label.config(text="True", fg='green')
        print(is_on)

# Create a button
Off_button = Button(root, width=5, height=2, bg="indian red", text='GaAs', bd=1, command = Switch_func)
Off_button.pack(pady=50)

root.mainloop()
