Tkinter.PhotoImage doesn’t not support png image

PIL is now replaced by Pillow http://pillow.readthedocs.io/en/3.2.x/

solution:

from Tkinter import *
import PIL.Image
import PIL.ImageTk

root = Toplevel()

im = PIL.Image.open("photo.png")
photo = PIL.ImageTk.PhotoImage(im)

label = Label(root, image=photo)
label.image = photo  # keep a reference!
label.pack()

root.mainloop()

If PIL could not be found in code, you do need a pillow install:

pip install pillow

Leave a Comment