Search code examples
pythontkinteridempotent

Is the tkinter grid geometry manager idempotent?


I believe the widget grid() method is idempotent -- that is, if I call it multiple times, there will be no different result. I could, for instance do this:

widget.grid(column=0, row=0)
widget.grid_remove()
n = 100
for i in range(n):
    widget.grid()

This code would be the same no matter the value of n. I cannot find a definitive answer in the tcl/tk docs, tkdocs.com, or the old NMT documentation.


Solution

  • Yes, if you call it multiple times, it will do the exact same thing each time you call it with the same parameters. The only call that has a lasting effect is the last time you call it.