Friday, 26 October 2018

Why is Button parameter “command” executed when declared?

My code is:

from Tkinter import *

admin = Tk()
def button(an):
    print an
    print 'het'

b = Button(admin, text='as', command=button('hey'))
b.pack()
mainloop()

The button doesn't work, it prints 'hey' and 'het' once without my command, and then, when I press the button nothing happens.



from Why is Button parameter “command” executed when declared?

No comments:

Post a Comment