Home > front end >  How to make button disappear in Python Tkinter
How to make button disappear in Python Tkinter

Time:01-24

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)

CodePudding user response:

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
  •  Tags:  
  • Related