在学习tkinter 模块,输入下面代码来编辑窗口背景
image1.png与该程序在同一文件目录下
from tkinter import *
win = Tk()
win.title("ceshi")
win.geometry("400x300")
photo = PhotoImage(file="image1.png")
imgLabel = Label(win,image = photo)
imgLabel.pack()
win.mainloop()
出现以下错误
Traceback (most recent call last):
File "c:\Users\asus\Desktop\新建文件夹 (4)\main2.py", line 5, in <module>
photo = PhotoImage(file="image1.png")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python 3.11\Lib\tkinter\__init__.py", line 4130, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\python 3.11\Lib\tkinter\__init__.py", line 4075, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "image1.png"
请求各位解答一下,谢谢。