Re: [Boa Constr] absolute vs relative paths
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2004-01-05 09:15:00
|
Hi Mike, Mike C. Fletcher wrote: > Bill Harris wrote: > >> I am trying to build a standalone executable of the Boa tutorial program >> Notebook using py2exe. I am running Windows XP Pro. >> >> I am running into the problem that the location for the bitmap in the >> dialog >> (wxDialog1) is an absolute path (e.g., c:\dir1\dir2\graphic.bmp). I >> need to >> somehow use a relative path, relative to the directory where the .exe >> will >> be installed. >> >> How can I do that? >> >> > (Shameless plug here.) > > If these are fairly small images, you can use ResourcePackage to store > the bitmap in a format that makes it part of the source-code so that you > load the image (regardless of py2exe'ing or inclusion of the code in > other projects) like so: > > from mypackage.myresources import my_image_png > doSomethingWithBitmap( my_image_png.getBitmap() ) > > This is the (rough) equivalent of embedding the image in a "resource" > file in a C++ project. The image is stored in a Python package, updated > automatically when you change it during development, and is imported as > a normal module, so it gets packed into your py2exe .exe file as part of > your source code. > > Some day I suppose I might get time to code a plug-in for Boa that does > the (fairly trivial) work of creating the resource package and using it > for storage of resources used by the GUI designer, but my time lately > for non-core projects is pretty fragmented & rare (anyone who feels like > doing it before me, feel free). You are welcome to add a resourcepackage plug-in for Boa. Be warned though that when I added the equivalent that wxPython provides (img2py) it was quite a challenge to have the new image format properly integrate with all designer image handling. It might be easier now with the initial groundwork laid out. Thanks, Riaan. |