How to set icon on wxFrame?

12,604

Solution 1

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.

Solution 2

Phoenix wxpython:

frame.SetIcon(wx.Icon("path/to/app.ico"))

Classic wxpython:

frame.SetIcon(wx.IconFromLocation("path/to/app.ico"))
Share:
12,604
User
Author by

User

Internet entrepreneur

Updated on June 04, 2022

Comments

  • User
    User almost 2 years

    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!

  • otterb
    otterb almost 10 years
    I do both for my app. For py2exe packaged app to show an icon on windows task bar, it's good idea to set an icon file with multiple sizes embedded. But, wx.Frame will need wx.Bitmap stuff.
  • Marcel Stör
    Marcel Stör over 7 years
    wx.IconFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ANY)) is a shortcut for that.
  • Sam Ginrich
    Sam Ginrich about 3 years
    @admin saw this is python domain, can be removed