gui.py 1.24 KB
import tkinter as tk


def clear_row(button, buttons):
    button_row = buttons[:3] if button in buttons[:3] else buttons[3:]

    for button in button_row:
        button.config(text='OFF')

def toggle_button(button):
    global buttons
    if button['text'] == 'ON':
        button.config(text='OFF')
    else:
        clear_row(button, buttons)
        button.config(text='ON')

def get_states():
    global buttons
    for i in range(3):
        if buttons[i].cget('text') == 'ON':
            mode = i
    mode = 0

    for i in range(3, 6):
        if buttons[i].cget('text') == 'ON':
            distortion = i - 3
    distortion = 0
    
    return mode, distortion



# Create the Tkinter window
window = tk.Tk()
window.title("Toggle Buttons")

# Create two frames for two rows
frame1 = tk.Frame(window)
frame1.pack(side=tk.TOP)

frame2 = tk.Frame(window)
frame2.pack(side=tk.TOP)

# Create six toggle buttons in two rows
buttons = []
for i in range(6):
    if i < 3:
        frame = frame1
    else:
        frame = frame2
    
    button = tk.Button(frame, text='OFF', width=10)
    button.config(command=lambda button=button: toggle_button(button))
    button.pack(side=tk.LEFT)
    buttons.append(button)

# Start the Tkinter event loop
window.mainloop()