What I need is to attach a function to a button that is called with a parameter. When I write the code as below however, the code is executed once when the button is created and then no more. Also, the code works fine if I get rid of the parameter and parentheses when I declare the function as an attribute of the button. How can I call the function with a parameter only when the button is pressed?
from Tkinter import *root =Tk()def function(parameter):print parameterbutton = Button(root, text="Button", function=function('Test'))
button.pack()root.mainloop()