|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #15章 label组件的学习
- from tkinter import *
- root = Tk()
- #创建一个文本Label对象
- textLabel = Label(root,\
- text = '你所下载的影片含有未成年人限制内容,请满18岁后再观看')
- textLabel.pack(side = LEFT)
- #创建一个图像Label对象,用photo实例化一个对象 注:这个地方报错,我py和图片是放同一个文件夹
- photo = PhotoImage(file = 'timg.jpg')
- imgLabel = Label(root, image = photo)
- imgLabel.pack(side = RIGHT)
- mainloop()
- '''
- Traceback (most recent call last):
- File "E:/pythontk/py15.2.py", line 14, in <module>
- photo = PhotoImage(file = 'timg.jpg')
- File "C:\Python34\lib\tkinter\__init__.py", line 3421, in __init__
- Image.__init__(self, 'photo', name, cnf, master, **kw)
- File "C:\Python34\lib\tkinter\__init__.py", line 3377, in __init__
- self.tk.call(('image', 'create', imgtype, name,) + options)
- _tkinter.TclError: couldn't recognize data in image file "timg.jpg"
- '''
复制代码
|
|