New to Tkinter. Initially, I had some code that was executing button commands at
creation, rather than waiting for user action. Some research here gave me a
solution, but I am not sure why the extra step is necessary.
This causes the "graph" function to execute when the button is created:
Button(root, text='OK', command=graph(c anvas)))
However, this waits until the button is pressed (the desired behavior):
def doit():
graph(canvas)
Button(root, text='OK', command=doit))
Functionally, what is the difference? Why do I need to create a function, to
call a function, simply to make a button command wait until pressed? Is there a
better method?
creation, rather than waiting for user action. Some research here gave me a
solution, but I am not sure why the extra step is necessary.
This causes the "graph" function to execute when the button is created:
Button(root, text='OK', command=graph(c anvas)))
However, this waits until the button is pressed (the desired behavior):
def doit():
graph(canvas)
Button(root, text='OK', command=doit))
Functionally, what is the difference? Why do I need to create a function, to
call a function, simply to make a button command wait until pressed? Is there a
better method?
Comment