I want to insert an image into my tkinter
but I received error:
TclError: image "pyimage7" doesn't exist.
I am using WinPython-64-3.3.5.9. I tried "rozmery.gif" but didn't help.
from tkinter import *
from PIL import ImageTk, Image
app_root = Tk()
#Setting it up
img = ImageTk.PhotoImage(Image.open("rozmery.png"))
#Displaying it
imglabel = Label(app_root, image=img).grid(row=1, column=1)
app_root.mainloop()
You should keep a reference to the image before placing it:
imglabel = Label(app_root, image=img)
imglabel.image = img
imglabel.grid(row=1, column=1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.