Skip to content Skip to sidebar Skip to footer

Changing Image With Button Click With Python Tkinter

I want to display 2 different images when a button is pressed. I have two images, and corresponding 2 buttons. I'm using the panel's configure function to try to change the image b

Solution 1:

To pass arguments to a button callback command, you need the lambda keyword, else the functions will be called at the time of button creation.

#place buttons
prev_button = tk.Button(window, text="Previous", width=10, height=2, command=lambda: prev(panel))
prev_button.pack(in_=bottom, side="left")
next_button = tk.Button(window, text="Next", width=10, height=2, command=lambda: next(panel))
next_button.pack(in_=bottom, side="right")

Post a Comment for "Changing Image With Button Click With Python Tkinter"