2016-05-24 63 views
0

私はグーグルグーグルで、問題を解決していないコードをいくつか修正しました。Python 2.7イメージ "pyimage does not exist"のTkinterラベル

マイコード:

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): 

File "", line 1, in
File "C:\Users\Asus\Anaconda2\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile execfile(filename, namespace) File "C:\Users\Asus\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "D:/AE theoretische Neuropsychologie/PythonReps/vCGPDM/Segmentation/extremePointsMotion.py", line 45, in w = Label(app, image=photo) File "C:\Users\Asus\Anaconda2\lib\lib-tk\Tkinter.py", line 2591, in init Widget.init(self, master, 'label', cnf, kw) File "C:\Users\Asus\Anaconda2\lib\lib-tk\Tkinter.py", line 2090, in init (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError: image "pyimage8" doesn't exist

[私がチェック物事]

https://www.daniweb.com/programming/software-development/threads/154237/tkinter-problem https://mail.python.org/pipermail/tutor/2002-May/014584.html

+0

でこの回答を見つけました(中に移動させた場合の後のコースすべてが)を示してください_complete_このエラーを示す作業プログラム。あなたは、ルートウインドウをいつどのように作成するのか、このコードが機能しているかどうかなど、多くの詳細を省いています。http://www.stackoverflow.com/help/mcveを参照してください。 –

+0

Ok I dont理由は分かっていますが、何とか今はapp = Tk()で動作しています このスレッドは閉じられている可能性があります – codingBeginner01

答えて

-1

が アプリの交換= Tkの()
アプリ=トップレベル()固定

では、しかし、新しい問題を作成しました:コードは2ウィンドウを生成します。両方のボタンとOneとの両方のラベルの付いた1 インデントではない、私は期待どおり

if __name__ == "__main__": 
app = Toplevel() 
app.title("Extreme Points in Motion Segmentation of BVHs") 
app.geometry('450x300+200+200') 
btnSelectF = Button(text='Open BVH File',width='20', command=callback) 
btnSelectF.pack() 
label = Label(app,text="no File selected",height=4) 
label.pack() 
photo = PhotoImage(file="D:/AE theoretische Neuropsychologie/PythonReps/vCGPDM/Segmentation/image.gif") 
w = Label(app, image=photo) 
w.photo = photo 
w.pack() 
btnCompute = Button(text='Compute Segmentation',width='20', command=computeSegmentation) 
btnCompute.pack() 
btnCompute.config(state="disabled") 
app.mainloop() 

はまた、私はソリューション

That's not really a proper fix because you rely on an imlicit root window created when the first widget is created. You end up with a variable root which isn't actually the true root window.

関連する問題