from tkinter import *
root = Tk()
photo = PhotoImage(file='blueface.png')
label = Label(root, image=photo)
label.pack()
root.mainloop()
The image face.png is in the same directory as this .py script, but when I run it, I get the following error:
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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…