1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| def toggle_buttons():
frame = nametowidget(cmdsWidget)
for name in 'b_create', 'b_destroy', 'b_other1', 'b_other2', 'b_other3':
b = frame.children[name]
state = b.configure('state')[-1]
if state in ("normal", "active"):
b.configure(state='disabled')
elif state == 'disabled':
b.configure(state='normal')
# Pas besoin de tester plus. Il n'y as que trois states.
def create_commands():
frame = nametowidget(cmdsWidget)
tk.Button(frame, text="Create", name="b_create",
command=create_widgets).pack(side=tk.LEFT)
tk.Button(frame, text="Other1", name="b_other1",
state='disabled').pack(side=tk.LEFT)
tk.Button(frame, text="Other2", name="b_other2",
state='disabled').pack(side=tk.LEFT)
tk.Button(frame, text="Other3", name="b_other3",
state='disabled').pack(side=tk.LEFT)
tk.Button(frame, text="Destroy", name="b_destroy", command=destroy_widgets,
state='disabled').pack(side=tk.LEFT)
tk.Button(frame, text="Quit", command=exit).pack(side=tk.LEFT) |