wxpythonwxwidgets

How to set icon on wxFrame?


How can I add an icon (.ico file) to a wxFrame?

I was looking in the docs but can't find any mention of icon.

Thanks!


Solution

  • I tried this setting in py2exe setup file, but it didn't do anything:

    windows = [
            {
                "script": "myscript.py",
                "icon_resources": [(1, "icon.ico")]
            }
        ],
    

    But this ended up working. Self is wx.Frame instance:

    icon = wx.EmptyIcon()
    icon.CopyFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ANY))
    self.SetIcon(icon)
    

    Hope this helps some others.