I'm trying to utilize partial in order to bind an image to it's associated name in a list "you'll see what I mean" but I'm getting a TypeError thrown on it, this is my first time trying to work with partials so I'm just not quite sure what's going on:

self.lab5.bind('<Button-1>',partial(self.search,val=mem[2]))
'''/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/'''
    def search(self,val):
        pop_up(val)

Traceback:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__
    return self.func(*args)
TypeError: search() got multiple values for keyword argument 'val'

any insight would be greatly appreciated!

Recommended Answers

All 4 Replies

also I've tried the same with

def search(self,val,event):
   pop_up(val)

to make sure it wasn't just an issue of it being clicked on and having an extra event, as happens when binding '<Return>' to something.

also I've tried the same with

def search(self,val,event):
   pop_up(val)

to make sure it wasn't just an issue of it being clicked on and having an extra event, as happens when binding '<Return>' to something.

I suggest search(self, val=None) .

@Tony: That worked perfectly, so not only did I fix the problem I learned which order events are taken. Thanks Tony and Gribouillis!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.