Python Forum

Full Version: Parameters for function in bind()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

self.canvas.bind("<B1-Motion>", self.move

I would like to call this function (self.move) also with some parameters, but I'm not sure, how to do it. This bind is inside a for loop, with variable 'i', and I want to call self.move with different values 'i'. Is there any way how to add a parameter to function in binding?
use partial, although I am just guessing as you didn't post enough code
from functools import partial
## rest of code
self.canvas.bind("<B1-Motion>", partial(self.move, i))