winfo_exists returns 1 if you did not destroy the widget, in which case it returns 0. This method can be called in any class of widgets, and not just in the root directory of Tk or Toplevels. In addition, you can get all widget children with winfo_children :
>>> import Tkinter as tk >>> root = tk.Tk() >>> label = tk.Label(root, text="Hello, world") >>> label.winfo_exists() 1 >>> root.winfo_children() [<Tkinter.Label instance at 0x0000000002ADC1C8>] >>> label.destroy() >>> label.winfo_exists() 0 >>> root.winfo_children() []
source share