|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
和课程例子代码一样,只是文件路径的有差别,标红部分,但不停报错。
报错信息:
---------------------------------------------------------------------------
TclError Traceback (most recent call last)
<ipython-input-8-cc75a9225398> in <module>
4
5 photo = PhotoImage(file = r"D:\百度云同步盘\Python材料\study\practice\hi.gif")
----> 6 imgLabel = Label(root,image = photo)
7 imgLabel(side = RIGHT)
8
~\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 "pyimage5" doesn't exist
或者还有报错的情况如下:
TypeError: 'Label' object is not callable
求大神们指导
代码:
from tkinter import *
root =Tk()
textLabel = Label(root,text="您所下载的页面不适合未成年人")
textLabel.pack(side = LEFT)
photo = PhotoImage(file = r"D:\百度云同步盘\Python材料\study\practice\hi.gif")
imgLabel = Label(root,image = photo)
imgLabel(side = RIGHT)
mainloop()
我刚刚试了你的代码,vscode没问题,感觉这种应该和工具有关,换一个好点,idle也香呀
|
|