How to use py2exe icon_resources in wxPython application?

I have a wxPython application that I am communicating with exe using py2exe. I defined the icon in the file setup.pyusing the following:

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

This works, but I would like to access this icon from my wxPython application and use it as the window icon that appears in the upper right corner. Currently, I use the following to download the icon from the file system:

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

Which works, but requires the icon to sit next to the EXE, and not be inserted inside it.

+3
source share
1 answer

I do this inside a subclass of Frame

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

Source: https://habr.com/ru/post/1735868/