If I run the code below, the button I targeted with the change function just turns blank instead of switching to the image I need.
import tkinter
from PIL import Image,ImageTK
root = tkinter.Tk()
root.geometry("800x800")
canvas = tkinter.Canvas(width="800",height="800")
canvas.pack()
#and for example a button would be
b1 = {"button": tkinter.Button(canvas),"index":"lorem ipusm", "img": image}
def change(button,pic):
photo = ImageTk.PhotoImage(pic)
button["button"].configure(image = photo)
button["img"] = pic
It only worked when I did this:
def change(button,pic):
photo = ImageTk.PhotoImage(pic)
button["button"].configure(image = photo)
button["button"]()
button["img"] = pic
I know that a button itself isn't callable, but with this it would word once, then throw an error that the button isn't callable.