I'm doing a small GUI in python, and I wanna add a button with an image. So I'm following what's said here : https://www.geeksforgeeks.org/python-add-image-on-a-tkinter-button/
It gives :
downimage = PhotoImage(file = "Downloadimage.png")
Dowloadbutton = Button(window, image=downimage, font=("Source Code Pro Light", 20), bg='black', fg='lime', command=start)
Dowloadbutton.pack()
As it is said in the link. But then the magic happens :
Traceback (most recent call last):
File "Keylogger.pyw", line 28, in <module>
downimage = PhotoImage(file = "Downloadimage.png")
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 3545, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 3501, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: CRC check failed
Line 28 corresponds to downimage = PhotoImage(file = "Downloadimage.png")
.
Everything else is packed and appear, but my button doesn't and gives me that error.
I don't know what it means, when I try to search it on internet, a lot of non-tkinter-related results appear, it seems to be not a common but still known error.
(I'm using the last version of both python and tkinter)
If you can help me, thank you really much ! Have a nice day ;)
In png format,CRC
code is here.
(An example png image)
It was encrypted(CRC32) by image chunk[0].It is a little hard for me to express that.
But the cause of your problem is the width and height of image is incorrect(mostly).Your image size has been revised.
In fact,if you put your image in linux
,the image couldn't be opened normally.In windows default image viewer,system will ignore CRC
checksum error,and you could open it.
How to solve your problem?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With