'hide a button after clicking it
I want to hide a button after the user clicks it how do I do it?
I've tried
def hide(widget):
widget.pack_forget()
btn2 = Button(master, text="no", command=lambda: hide(btn2))
btn2.place(x=200, y=70)
the program runs but the button doesn't hide
Solution 1:[1]
If you use .place() to put the button on the window you have to use .place_forget() to remove it:
# create the button
btn2 = Button(master, text="no", command=btn2.place_forget)
# place the button
btn2.place(x=200, y=70)
# remove the button
btn2.place_forget()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom |
