|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from tkinter import *
root = Tk()
textLabel = Label(root, text = "一张图片!")
textLabel.pack()
photo = PhotoImage(file = "11.jpg")
imgLabel = Label(root, image = photo)
imgLabel.pack()
mainloop()
运行后报错:
Traceback (most recent call last):
File "G:/python学习/object/tkinter/065练习1.py", line 10, in <module>
photo = PhotoImage(file = "11.jpg")
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 3539, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 3495, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "11.jpg"
这是tkinter模块出错了吗
不支持gif以外的格式,
用画图打开另存为gif
还有如果不是py一个文件夹,要写全路径
|
|