Reputation: 11
I googlet a lot and made some adaptions to my code which still didn't fix the problem.
My Code:
photo = PhotoImage(file="D:/AE theoretische Neuropsychologie/image.gif")
w = Label(app, image=photo)
w.photo = photo
w.pack()
Gives me the following Error (-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
[Things I checked]
https://www.daniweb.com/programming/software-development/threads/154237/tkinter-problem https://mail.python.org/pipermail/tutor/2002-May/014584.html
Upvotes: 0
Views: 2629
Reputation: 11
Replacing
app = Tk()
with
app = Toplevel()
fixed, however created a new Problem: The code now produces 2 windows. One with both Buttons and one with the both labels indentation not as I expect (of course everything after if is moved in)
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()
Also I found this reply on the Solution
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.
Upvotes: -1