On Aug 8, 2009, at 9:13 AM, Brendan Simon (eTRIX) wrote:
I have a jpg image which is displayed in my wxPython app. It is
loaded
from an 'image' directory.
eg. image/mypic.jpg
This works fine when I type "python mywxapp" from the command line,
but
when I build an app bundle it doesn't work.
I've tried two options (see below). Both copy the jpg to the
Resourses
directory, but I loose the images/ directory.
What's the best/appropriate way to get image files in the app ??
It has
to work with manual invocation too.
Try this in setup.py, which will put the images in an 'images'
subdirectory under Resources in your app bundle:
DATA_FILES = [ ('images', 'images/mypic.jpg') ]
OPTIONS = { 'argv_emulation' : True }
Then do something like this in your app:
imagedir = os.path.join(os.environ.get('RESOURCEPATH', '.'), 'images')
mypic = os.path.join(imagedir, 'mypic.jpg')
The RESOURCEPATH environment variable is set by py2app. If it exists,
you can assume that the app is bundled and adjust the image path
accordingly.
~ Daniel
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig