B.Hawkins
B.Hawkins

Reputation: 363

Python, how to call 2 functions from the same Event

Good evening all,

I have an event, Button1, bound to an image to make it clickable. Once it has been clicked it goes to a function. However, i need the Event to go to 2 different function at the same time. The Event works with 1 function at a time (both work but not together) so i presume i am just formatting the Event wrong.

self.img_list[2].bind('<Button-1>', removewidgetsHome)

I have tried:

self.img_list[2].bind('<Button-1>', removewidgetsHome, feedbackpage)

But to no avail.

For those who are interested here is my full code

Upvotes: 0

Views: 592

Answers (2)

Michael0x2a
Michael0x2a

Reputation: 63978

You could perhaps make a third function that calls the other two rather then trying to figure out how to bind multiple functions:

def combined(*args, **kwargs):
    remove_widgets_home(*args, **kwargs)
    feedback_page(*args, **kwargs)

# ...snip...

self.img_list[2].bind('<Button-1>', combined)

Upvotes: 5

fakedrake
fakedrake

Reputation: 6856

Or for a one liner you could try:

self.img_list[2].bind('', lambda *args: (remove_widgets_home(*args), feedback_page(*args))

Upvotes: 0

Related Questions