如何在 wxFrame 上设置图标? [英] How to set icon on wxFrame?

查看:41
本文介绍了如何在 wxFrame 上设置图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向 wxFrame 添加图标(.ico 文件)?

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

我正在查看 docs 但不能查找任何提及 icon 的内容.

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

谢谢!

推荐答案

我在 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.

这篇关于如何在 wxFrame 上设置图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆