0

In the following code, I ran the following code with the intention of opening an image in a tkinter window.

from tkinter import *
root = Tk()

photo = PhotoImage(file = "/path/to/file/myimg.gif")
w = Label(root, image=photo)
w.pack()
ent = Entry(root)
ent.pack()
ent.focus_set()

canvas= Canvas(root, width=800, height=500)
canvas.pack()

root.mainloop()

However, it outputs _tkinter.TclError: couldn't recognize data in image file "/path/to/file/myimg.gif"

I read somewhere that PhotoImage can only read from a few file formats, but that GIF is one of them (and jpeg is not). Is there some other error?

Aidan Tung
  • 55
  • 6

0 Answers0