且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 wxFrame 上设置图标?

更新时间:2023-09-29 22:54:28

我在 py2exe 安装文件中尝试了这个设置,但它没有做任何事情:

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

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

但这最终奏效了.self 是 wx.Frame 实例:

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.