Skip to content
Advertisement

Binding event to combobox selection to display image inside Toplevel window (Tkinter Python)

I am attempting to bind a selection event to items within a combobox to display an image inside a toplevel window once the specified item is selected. The code I have runs without error. However, the images are not displayed upon selecting the items inside the combobox. Any help would be appreciated.

JavaScript

Advertisement

Answer

This is a subtle issue with binding the callback to the Combobox event, you need to pass in a function as an argument, but you wrote

JavaScript

with the parenthesis after self.CMBinsert, so you’re not passing the function, you’re actually calling the function once, and passing in the result instead. Just remove those parenthesis:

JavaScript

After that, you get an error on the callback’s signature:

JavaScript

because it’s expecting an event parameter, just change your def to:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement