Posts

Showing posts with the label call

How can I pass in parameters without calling a function in Python? [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP How can I pass in parameters without calling a function in Python? [duplicate] This question already has an answer here: I am using the Tkinter bind function, and I would like to bind a button to a function. However, this function takes parameters (which, for obvious reasons, I have put in parentheses). encrypt_button = Button(window, text='Encrypt') encrypt_button.bind('<Button-1>', bl_encrypt(foo)) My problem is that, since I am passing 'foo' into my function, the function is called whenever the program gets to this line, not when I click on the button. This would not usually happen as, if there were no parameters to be passed, I would not put parentheses after the function name. How do I bind to this function and pass parameters, but without the function being called as soon as I run the program? My Python version is 3.6.0, if that helps. This question has been asked before and already has an answer. If those answe...