Ripseed Oil
Ripseed Oil

Reputation: 77

Tkinter PhotoClass (couldn't recognize data in image file)

I am trying to load a gif image into my tkinter GUI and I am using PhotoClass().Please note that I am not using any external modules such as PIL.I am using python 3.4. At first I tried a .png image,which is not supported natively.So I changed the image extension to .gif, which (I believe) is supported.

The image is first refrenced here:

img=tk.PhotoImage(file="Image.gif")

And is placed into a Label here:

ImageLabel=tk.Label(root, image=img,)
ImageLabel.grid(row=14,column=1)

The error I receive is:

_tkinter.TclError: couldn't recognize data in image file "Image.gif"

Any help would be greatly appreciated.

Upvotes: 0

Views: 947

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386020

You can’t just change the extension to magically convert a file to a different format. Tkinter is expecting GIF data, doesn’t get it, and thus throws the error that the data can’t be recognized. You must give it actual GIF data.

Upvotes: 1

Related Questions