小编And*_*y G的帖子

tkinter PhotoImage 不存在?

from tkinter import *

root = Tk()

photo = PhotoImage(file='blueface.png')
label = Label(root, image=photo)
label.pack()

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

图像 face.png 与此 .py 脚本位于同一目录中,但是当我运行它时,出现以下错误:

 line 5, in <module>
    photo = PhotoImage(file='blueface.png')
 line 3539, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
 line 3495, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "face.png": no such file or directory
Run Code Online (Sandbox Code Playgroud)

python tkinter

5
推荐指数
1
解决办法
6426
查看次数

标签 统计

python ×1

tkinter ×1