Tkinter supports a variety of methods to perform various tasks. It also offers some universal method.
destroy() is a universal widget method i.e we can use this method with any of the available widgets as well as with the main tkinter window.
Syntax:
widget_object = Widget(parent, command = widget_class_object.destroy)
This method can be used with
after() method.
Code #1: destroy() method passed as command
Output:
👁 destroy() method in Tkinter
As you may observe, in above code that the command that is passed in button-2 is to destroy button-1 so as soon as you press button-2, button-2 will get destroyed.
👁 destroy() method passed as command
Code #2:destroy() method with after() method