# Imports tkinter and ttk modulefromtkinterimport*fromtkinter.ttkimport*# toplevel windowroot=Tk()# method to make widget invisible# or remove from topleveldefforget(widget):# This will remove the widget from toplevel# basically widget do not get deleted# it just becomes invisible and loses its position# and can be retrievewidget.grid_forget()# method to make widget visibledefretrieve(widget):widget.grid(row=0,column=0,ipady=10,pady=10,padx=5)# Button widgetsb1=Button(root,text="Btn 1")b1.grid(row=0,column=0,ipady=10,pady=10,padx=5)# See, in command forget() method is passedb2=Button(root,text="Btn 2",command=lambda:forget(b1))b2.grid(row=0,column=1,ipady=10,pady=10,padx=5)# In command retrieve() method is passedb3=Button(root,text="Btn 3",command=lambda:retrieve(b1))b3.grid(row=0,column=2,ipady=10,pady=10,padx=5)# infinite loop, interrupted by keyboard or mousemainloop()