[wxPython-users] Retrieving a resource bitmap from a py2exe application

Peter Damoc pdamoc at gmail.com
Mon Apr 2 07:50:49 PDT 2007


Hi Artur,

The way I handled this issue was using a global for the homePath
like this:

__builtin__.__dict__['homePath'] =3D os.path.abspath(os.path.dirname(sys.ar=
gv
[0]))

this pushes the path of the executable in the homePath global

and then I join the needed files using os.path.join to the relative path
from the executable.
For example I have the images in the "images" folder so to get "start.png" I
write:
os.path.join(homePath, "images/start.png")

Peter.

On 4/2/07, Artur Matos <arturmatos78 at yahoo.com> wrote:
>
> Hi to all,
>
> I have an application that displays a fixed bitmap,
> and I am packaging this application as a windows .exe
> file, using py2exe. I am trying to add the bitmap as a
> windows resource, so that it gets packaged inside the
> .exe file. py2exe has a bitmap_resources options that
> allow us to do this, so I've added something like this
> to my setup.py file:
>
> setup(
> windows=3D [
>   {
>    ...
>    "bitmap_resources": [(1, "a.bmp")
>    ...
>
> The problem is on how to access this bitmap from the
> wxPython application. The wiki has some explanation on
> how to do this for icons, but not for bitmaps. I have
> tried to do something similar to what is written in
> the wiki, something like this:
>
> # Gets the name of the application
> exe_name =3D
> win32api.GetModuleFileName(win32api.GetModuleHandle(None))
> # Retrieves the bitmap
> bitmap =3D wx.Bitmap("%s;%s" % (exe_name, 1),
> wx.BITMAP_TYPE_BMP)
>
> But this is not working, and I only get an empty
> bitmap. I have noticed that the wxWidgets C++
> documentation has a wxBITMAP_TYPE_BMP_RESOURCE bitmap
> type, so I thought that using that should solve the
> problem, but this type is not defined in wxPython.
> Does anyone has any sugestions to solve this? I am
> using wxPython 2.8.
>
> Best regards,
>
> Artur Matos.
>
>
>
>
> _________________________________________________________________________=
___________
> Bored stiff? Loosen up...
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>


-- =

There is NO FATE, we are the creators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200704=
02/b2d828de/attachment.htm


More information about the wxpython-users mailing list