|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 lanshj 于 2020-6-17 16:07 编辑
- from tkinter import *
- from PIL import Image, ImageTk
- root = Tk()
- textLabel = Label(root,text = '您所下载的影片有未成年限制内容,请慢18岁后再观看')
- textLabel.pack()
- #因为tk本身的只支持gif图片,所以要用到其他模块辅助
- img = Image.open('rua.jpg') # 打开图片
- photo = ImageTk.PhotoImage(img) # 用PIL模块的PhotoImage打开
- imgLabel = Label(root,image=photo)
- imgLabel.pack()
- mainloop()
复制代码
看起来没问题,但是报错如下
---------------------------------------------------------------------------
TclError Traceback (most recent call last)
<ipython-input-13-b741380ad525> in <module>
11 photo = ImageTk.PhotoImage(img) # 用PIL模块的PhotoImage打开
12
---> 13 imgLabel = Label(root,image=photo)
14 imgLabel.pack()
15
~\Anaconda3\lib\tkinter\__init__.py in __init__(self, master, cnf, **kw)
2764
2765 """
-> 2766 Widget.__init__(self, master, 'label', cnf, kw)
2767
2768 class Listbox(Widget, XView, YView):
~\Anaconda3\lib\tkinter\__init__.py in __init__(self, master, widgetName, cnf, kw, extra)
2297 del cnf[k]
2298 self.tk.call(
-> 2299 (widgetName, self._w) + extra + self._options(cnf))
2300 for k, v in classes:
2301 k.configure(self, v)
TclError: image "pyimage9" doesn't exist |
|