Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # checkbutton_group_io
- from Tkinter import *
- root = Tk()
- a='a'
- b='b'
- label = {}
- root.grid_rowconfigure(0,weight=1)
- root.grid_columnconfigure(0,weight=1)
- root.config(background="lavender")
- label[a] = Label(root, bg='yellow')
- label[a].pack(side='left')
- label[b] = Label(root, bg='blue')
- label[b].pack(side='right')
- button = {}
- aaa = IntVar()
- bbb = IntVar()
- def click(item,var):
- if var.get():
- io='disabled'
- else:
- io='normal'
- for w in label[item].winfo_children()[1:]:
- w.configure(state=io)
- def fn(e):
- print e
- check_a = Checkbutton(label[a], text=" Group A ", variable=aaa, command=lambda e=a, v=aaa: click(e,v))
- check_a.grid(row=0, column=0)
- for i in range(5):
- button[b] = Button(label[a], text='Button '+str(i), command=lambda e='Group A: '+str(i): fn(e))
- button[b].grid(row=i+1, column=0)
- check_b = Checkbutton(label[b], text=" Group B ", variable=bbb, command=lambda e=b, v=bbb: click(e,v))
- check_b.grid(row=0, column=1)
- for i in range(5):
- button[a] = Button(label[b], text='Button '+str(i), command=lambda e='Group B: '+str(i): fn(e))
- button[a].grid(row=i+1, column=1)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement