|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- root = Tk()
- textLabel = Label(root,text="这是一位美女:")
- textLabel.pack(side=LEFT)
- photo = PhotoImage(file="1.gif")
- imgLabel = Label(root,image=photo)
- imgLabel.pack(side=RIGHT)
- mainloop()
复制代码
我的图片原来是jpg格式,我把后缀改成了gif,如图。但是运行出错,无法识别gif格式图片。求助!
Traceback (most recent call last):
File "C:\Users\dwc\Desktop\test\tkinter\tk2.py", line 8, in <module>
photo = PhotoImage(file="1.gif")
File "E:\python36\lib\tkinter\__init__.py", line 3539, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "E:\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 "1.gif"
谁告诉过你将后缀名改了就是了?
去百度一下gif和jpg之类的文件区别
|
|