so for example
window = Tk()
lbl = Label(text='abc')
lbl.place(x=1, y=1)
lbl2 = Label(text='ABC')
lbl2.place(x=2, y=2)
numOfWidgets = window.amount
print(str(numOfWidgets))
>>> 2
Does anyone know if there is a way to do this?
so for example
window = Tk()
lbl = Label(text='abc')
lbl.place(x=1, y=1)
lbl2 = Label(text='ABC')
lbl2.place(x=2, y=2)
numOfWidgets = window.amount
print(str(numOfWidgets))
>>> 2
Does anyone know if there is a way to do this?
The method winfo_children
will return the children of a given window. You can use that information to iterate through all of the widgets if you need a count of all widgets in an application.
In your case, len(window.winfo_children())
will return 2
.