views:

202

answers:

1

I have a wxPython application I'm bundling into an exe using py2exe. I've defined an icon in the setup.py file using the following:

setup(
    windows=[
        {
            'script': 'myapp.py',
            'icon_resources': [(1, 'myicon.ico')]
        },
    ],
)

This works, but I'd like to be able to access that icon from my wxPython application and use it as the window icon that appears in the top right. Currently I'm using the following to load the icon from the file system:

icon = wx.Icon('myicon.ico', wx.BITMAP_TYPE_ICO, 16, 16)
self.SetIcon(icon)

Which works, but requires that the icon sit beside the EXE, rather than bundled inside it.

+2  A: 

I do this inside the Frame subclass

if os.path.exists("myWxApplication.exe"):
     self.SetIcon(wx.Icon("myWxApplication.exe",wx.BITMAP_TYPE_ICO))
S.Mark
Very cool, I had no idea you could derive a bitmap from the exe itself. Unless someone comes up with an answer on how to directly access the icon_resources, this is going to be the answer.
Soviut
The idea comes from Windows Icon setting, you could choose from any .exe,.dll files, And of course, I would happy to know direct approach too :-)
S.Mark