Mar-06-2024, 08:50 PM
You need to keep a reference to the image. I would do it like this:
Adding a variable to the label that references the image prevents this from happening.
image3 = ImageTk.PhotoImage(resimage_download) image_download = tk.Label(window, image=image3, borderwidth=0) image_download.place(x=62, y=240) image_download.image = image3When you use an image in a label, tkinter does not keep a reference to the image object. image3 was the only reference to the image. When the read_column function returned, all local variables from that function cease to exist. There is no longer an image3 variable, so there is nothing that references the variable. Python assumes you no longer need the image, not a bad assumption as there is no way you can do anything with the image, so it deletes the image garbage collects the image memory.
Adding a variable to the label that references the image prevents this from happening.