|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是我的源代码,根据小甲鱼老师的python入门版的第65课代码敲得,结果又有错误,尝试并未解决,实在太菜,求大神指教。
from tkinter import *
root = Tk()
textLabel = Label(root, text="禁止观看")
textLabel.pack(side=LEFT)
photo = PhotoImage(file="cat.jpg")
imgLabel = Label(root, image=photo)
imgLabel.pack(side=RIGHT)
mainloop()
下面是问题描述
D:\Python\python.exe E:/ptcharm/tk3.py
Traceback (most recent call last):
File "E:/ptcharm/tk3.py", line 8, in <module>
photo = PhotoImage(file="cat.jpg")
File "D:\Python\lib\tkinter\__init__.py", line 3539, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "D:\Python\lib\tkinter\__init__.py", line 3495, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "cat.jpg": no such file or directory
cat.gif 图片跟程序文件都是在一个文件夹里的
我猜测:会不会文件名其实是 cat.gif,但你指定的确实 cat.jpg?
|
|