I just started with my first Python program and ran into a pretty strange issue with function callback. Here is the code that matches my expectation:
from tkinter import *
def say_hello():
print('hello')
root = Tk()
Button(root, text='say hello', command=say_hello).pack()
root.mainloop()
Now if I add parentheses to the function name
Button(root, text='say hello', command=say_hello()).pack()
'hello' will be printed only once when the program starts, but nothing further happens when the button is clicked. Why?
Thanks!