Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_io_buttons.py
- import Tkinter as tk
- def __init__(master):
- frame = Frame(master)
- frame.pack()
- def toggle_text():
- if button["text"] == "NO":
- button["text"] = "YES"
- label["bg"] = "green"
- button["bg"] = "lightgray"
- else:
- button["text"] = "NO"
- label["bg"] = "red"
- button["bg"] = "darkgray"
- def toggle_text1():
- if button1["text"] == "NO":
- button1["text"] = "YES"
- label1["bg"] = "green"
- button1["bg"] = "lightgray"
- else:
- button1["text"] = "NO"
- label1["bg"] = "red"
- button1["bg"] = "darkgray"
- def toggle_text2():
- if button2["text"] == "NO":
- button2["text"] = "YES"
- label2["bg"] = "green"
- button2["bg"] = "lightgray"
- else:
- button2["text"] = "NO"
- label2["bg"] = "red"
- button2["bg"] = "darkgray"
- root = tk.Tk()
- root.title("GUI - TEST")
- button = tk.Button( text="NO", width=12, command=toggle_text, bg='darkgray')
- button.grid(row=0, column=1)
- label = tk.Label(bg='red', width=6, text='1')
- label.grid(row=0, column=2)
- button1 = tk.Button( text="NO", width=12, command=toggle_text1, bg='darkgray')
- button1.grid(row=1, column=1)
- label1 = tk.Label(bg='red', width=6, text='2')
- label1.grid(row=1, column=2)
- button2 = tk.Button( text="NO", width=12, command=toggle_text2, bg='darkgray')
- button2.grid(row=2, column=1)
- label2 = tk.Label(bg='red', width=6, text='3')
- label2.grid(row=2, column=2)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement