[PythonCE] Tkinter PhotoImage, no such file or directory
Michael Foord
fuzzyman at voidspace.org.uk
Sun Apr 30 11:57:33 CEST 2006
Patrick Kramer wrote:
> <quote who="Luke Dunstan">
>
>> You can tell Python using os.chdir(), but that will not necessarily have any
>> effect on Tkinter because the operating system has no concept of a "current
>> directory", so it depends on whether the image file is opened in the Python
>> code or the C code.
>>
>> Luke
>>
>>
>
> So there is no way for python to return the current directory it is in?
>
> say something like:
>
> dir = return_dir()
>
> image_loc = dir + "//BtnGluco.gif"
>
> Or:
>
> image_loc = dir + "//assets//img//BtnGluco.gif" #This is how I would like to orgnize it
>
I think the situation is (perhaps Luke can correct me if I'm wrong) :
The underlying Windows CE platform has no concept of a current directory.
PythonCE *simulates* a current directory on the python level
This means that calls that use only Python code will work as normal -
except the current directory will always start in a fixed location
('//Temp' I think).
Calls to use files from C code will not have access to this information.
So you can experiment with the image_loc and see if it works using the
current directory or not, but it may not do.
To get the current directory you use the normal functions provided by
the ``os`` and ``os.path`` module :
cur_dir = os.getcwd()
print cur_dir
os.chdir(""//assets")
print os.getcwd()
image_path = os.path.join(os.getcwd(), "img//BtnGluco.gif")
You can also test whether you are running on windows CE or not with either :
sys.platform or sys.getwindowsversion()
They should return different things on windows CE and normal windows.
That means you can make your code behave appropriately depending on
which system it is on.
HTH
Fuzzyman
http://www.voidspace.org.uk/python/shareware.shtml
> _______________________________________________
> PythonCE mailing list
> PythonCE at python.org
> http://mail.python.org/mailman/listinfo/pythonce
>
>
More information about the PythonCE
mailing list