File Location

22 views
Skip to first unread message

vweb.we...@gmail.com

unread,
Jun 21, 2015, 10:45:26 PM6/21/15
to ie...@googlegroups.com
I'm using tkinter with the default python shell (2.7).

When I try to load images, like a window icon or PhotoImage, it does not locate the image files.

All I want the program to do is load images from the folder where the .py file is located. Can anyone explain how to get IEP to do that?

I see a startDir setting in the Shell configuration, but I don't know what to put in there. I don't want to set it to a specific folder. I just always want it to load images from the same folder the .py file is located in.

Ludo Visser

unread,
Jun 22, 2015, 3:04:29 AM6/22/15
to ie...@googlegroups.com
If you run the file as a script (from the “Run” menu), the shell should change the current directory to the directory of the .py file that is being executed.

 - Ludo

--
You received this message because you are subscribed to the Google Groups "Interactive Editor for Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iep_+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Almar Klein

unread,
Jun 22, 2015, 6:36:03 AM6/22/15
to ie...@googlegroups.com
Just wanted to add:

1) using absolute locations is usually less prone to error, because the
current directory can be changed without you knowing it.

2) On Windows, either use "c:/foo/bar" or "c:\\foo\\bar", or
r"c:\foo\bar" (not the 'r' in front).

- Almar

On 22-06-15 09:04, Ludo Visser wrote:
> If you run the file as a script (from the “Run” menu), the shell should
> change the current directory to the directory of the .py file that is
> being executed.
>
> - Ludo
>
>> Op 22 jun. 2015, om 04:45 heeft vweb.we...@gmail.com
>> <mailto:vweb.we...@gmail.com> het volgende geschreven:
>>
>> I'm using tkinter with the default python shell (2.7).
>>
>> When I try to load images, like a window icon or PhotoImage, it does
>> not locate the image files.
>>
>> All I want the program to do is load images from the folder where the
>> .py file is located. Can anyone explain how to get IEP to do that?
>>
>> I see a startDir setting in the Shell configuration, but I don't know
>> what to put in there. I don't want to set it to a specific folder. I
>> just always want it to load images from the same folder the .py file
>> is located in.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Interactive Editor for Python" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to iep_+uns...@googlegroups.com
>> <mailto:iep_+uns...@googlegroups.com>.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Interactive Editor for Python" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to iep_+uns...@googlegroups.com
> <mailto:iep_+uns...@googlegroups.com>.

vweb.we...@gmail.com

unread,
Jun 23, 2015, 12:29:03 AM6/23/15
to ie...@googlegroups.com
Oh, beautiful. :)

I don't know why I didn't try that. That works perfectly.

Thank you. 
Reply all
Reply to author
Forward
0 new messages