Python tkinter binding a function with multiple parameters Python tkinter binding a function with multiple parameters tkinter tkinter

Python tkinter binding a function with multiple parameters


Here you're binding the result of someFunction (or trying to anyway). This fails because when python tries to get the result of someFunction, it calls it only passing 1 argument ("Hello") when someFunction really expects 2 explicit arguments. You probably want something like:

self.canvas.bind('<Button-1>',lambda event: self.someFunction(event,"Hello"))

This binds a new function (which is created by lambda and wraps around self.someFunction) which passes the correct arguments.


Or,

def someFunction(self, string):   def fn(*arg)      print string   return fnself.canvas.bind("<Button-1>",self.someFunction("Hello!"))