Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make button disappear in Python Tkinter

I want to make Tic Tac Toe game and I want to button disappear when it’s clicked, I searched on SO and I have this code but it doesn’t work, why? Idk. Code:

def hide_me(event):
    event.widget.grid_forget()

def callback(Buttons):
   Buttons.bind('<Button>', hide_me)


def callback_and_hide(button):
    callback(Play_Button1)
    button.grid_forget()

Play_Button1 = Button(master = window,text='ㅤㅤ',command=lambda: callback_and_hide(Play_Button1))
Play_Button1.config(bg="white",fg="black")
Play_Button1.place(x=54, y=157, width=61, height=61)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You aren’t using grid, so calling grid_forget() will have no effect. Each of the geometry managers have their own variations, and you must use the one related to the geometry manager you’re using:

  • grid_forget
  • grid_remove
  • pack_forget
  • place_forget
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading