Tkinter

How to Delete Tkinter Button After Click

In this tutorial, we are going to see how to delete Tkinter button after click in Python. to remove a widget from the Tkinter window, you can call the method pack_forget()(use pack() to add it to the window).
 

 

How to Delete Tkinter Button After Click
from tkinter import *

root = Tk()
root.geometry('200x100')  

b = Button(root, text="Destroy me", command=lambda: b.pack_forget())
b.pack(pady=20)

root.mainloop()

Output:


 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *