0
import tkinter as tk
from tkinter import *
from PIL import ImageTk, Image
from PIL import ImageTk, Image


class App(tk.Tk):

    def __init__(self):
        tk.Tk.__init__(self)
        self.geometry("65x65+1450+700")

        self.photo = PhotoImage(file="uchiha.jpg")
        self.btn = Label(image=self.photo, relief=tk.FLAT, bd=0)
        self.btn.pack()
        #self.overrideredirect(True)


app = App()
app.mainloop()

In this program I am getting an error in tkinter saying: _tkinter.TclError: couldn't recognize data in image file "uchiha.jpg". How do I fix this error. The file is not corrupted or anything.

  • 1
    `tkinter.PhotoImage()` does not support JPEG image, use `ImageTk.PhotoImage()` instead. However your code still has other [issue](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) after fixing this issue. – acw1668 Dec 14 '21 at 14:58
  • I changed it to .png an am still getting the same error. I didin't get the issue in my code stll. – zaper newlson Dec 14 '21 at 15:44
  • How do you change it? Just renaming it from `.jgp` to `.png` does not work. Did you try using `ImageTk.PhotoImage()`? – acw1668 Dec 14 '21 at 23:03
  • I tried now, it works perfectly thank you. – zaper newlson Dec 15 '21 at 02:49

0 Answers0