Re: Tkinter PhotoImage, no such file or directory

"Luke Dunstan" <[email protected]>
Newsgroups gmane.comp.python.windows-ce
Message-ID <[email protected]>
----- Original Message ----- 
From: "Patrick Kramer" <[email protected]>
To: <[email protected]>
Sent: Friday, April 28, 2006 3:30 PM
Subject: [PythonCE] Tkinter PhotoImage, no such file or directory


>I have two files which are both in the PyGlucoCE directory off of root.
>
> Tkintertest.py
> BtnGluco.gif
>
>
>
> Here is my code:
>
> import sys
>
> sys.path.append('\\Program Files\\Python24\\python24.zip\\lib-tk')

This looks OK.

> sys.path.append('\\PyGlucoCE')

What is the purpose of the above line? I don't think you are importing any 
modules from that directory.

> from Tkinter import *
>
> root = Tk()
>
> ImgGlucose = PhotoImage(file = 'BtnGluco.gif')

I think that should be: ImgGlucose = PhotoImage(file = 
'\\PyGlucoCE\\BtnGluco.gif')

On the other hand, I don't know Tkinter so I may be wrong. Does Tkinter 
search sys.path for image files?

>
> print ImgGlucose.height()
>
> b = Button(root, image=ImgGlucose)
> b.image = ImgGlucose
> b.pack()
>
> root.mainloop()
>
>
>
> Now I get this error:
>
> _tkinter.TclError: couldn't open "BtnGluco.gif": no such file or directory
>
>
>
>
> The weird part is I get the same error within Pydev, but if I run the 
> script straight through commandline, it works and shows the image as a 
> button.

What is Pydev, and which command line are you talking about? Windows CE or 
Windows XP?

Luke

>
> My guess is I screwed up the path append, but it looks correct to me :/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.