【发布时间】:2016-05-24 21:13:58
【问题描述】:
我用谷歌搜索了很多,并对我的代码进行了一些修改,但仍然没有解决问题。
我的代码:
photo = PhotoImage(file="D:/AE theoretische Neuropsychologie/image.gif")
w = Label(app, image=photo)
w.photo = photo
w.pack()
给我以下错误(-tracebacks)
Traceback (most recent call last):文件“”,第 1 行,在
文件 "C:\Users\Asus\Anaconda2\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", 第 699 行,在运行文件中 execfile(文件名,命名空间)文件“C:\Users\Asus\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”, 第 74 行,在 execfile 中 exec(compile(scripttext, filename, 'exec'), glob, loc) File "D:/AE theoretische 神经心理学/PythonReps/vCGPDM/Segmentation/extremePointsMotion.py", 第 45 行,在 w = 标签(应用程序,图像=照片)文件“C:\Users\Asus\Anaconda2\lib\lib-tk\Tkinter.py”,第 2591 行,在 初始化 Widget.init(self, master, 'label', cnf, kw) 文件“C:\Users\Asus\Anaconda2\lib\lib-tk\Tkinter.py”,第 2090 行,在 初始化 (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError:图像“pyimage8”不存在
[我检查的内容]
https://www.daniweb.com/programming/software-development/threads/154237/tkinter-problem https://mail.python.org/pipermail/tutor/2002-May/014584.html
【问题讨论】:
-
请展示一个说明此错误的完整工作程序。您遗漏了很多细节,例如创建根窗口的方式和时间、此代码是否在函数中等。请阅读stackoverflow.com/help/mcve
-
好吧我不知道为什么,但不知何故它现在只适用于 app = Tk() 所以这个线程可以关闭
标签: image python-2.7 tkinter label