Python Forum
Parameters for function in bind() - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Parameters for function in bind() (/thread-17636.html)



Parameters for function in bind() - kom2 - Apr-18-2019

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?


RE: Parameters for function in bind() - woooee - Apr-18-2019

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))