Soviut
Soviut

Reputation: 91545

How to use py2exe icon_resources in wxPython application?

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.

Upvotes: 3

Views: 2222

Answers (1)

YOU
YOU

Reputation: 123831

I do this inside the Frame subclass

if os.path.exists("myWxApplication.exe"):
     self.SetIcon(wx.Icon("myWxApplication.exe",wx.BITMAP_TYPE_ICO))

Upvotes: 4

Related Questions