任务栏的wxpython图标 [英] wxpython icon for task bar

查看:1709
本文介绍了任务栏的wxpython图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的wxpython程序中设置一个图标。到目前为止,在阅读了许多页面和示例之后,我能够在窗口设置一个图标,这在使用alt + tab时也有效(我在Windows 7上工作)。

I am trying to set an icon in my wxpython program. So far, after reading many pages and examples, I was able to set an icon at the window, which also works when using alt+tab (I'm working over Windows 7).

但任务栏上的图标是通常的python默认图标。

But the icon at task bar is the usual python default icon.

我不明白为什么这么简单的任务会有这么多麻烦。

I don't understand why are there so many troubles for such a simple task.

这是我的代码:

class GraphFrame(wx.Frame):
    """ The main frame of the application
    """
    title = 'My first wxprogram'

    def __init__(self):
        wx.Frame.__init__(self, None, -1, self.title)

        ico = wx.Icon('dog.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(ico)
        self.set_icon  

        self.create_menu()
        self.create_status_bar()
        self.create_main_panel()
        #...


推荐答案

目前无法通过w设置任务栏图标xPython(除非你破坏了系统变量),这是因为windows从可执行文件中获取应用程序图标(在你的情况下是Python)

It's currently not possible to set the taskbar icon via wxPython (Unless you hack apart the system variables), this is because windows gets the application icon from the executable (Which in your case is Python)

如果你使用 pyinstaller py2exe (我更喜欢前者),编译时可以设置应用程序图标 - 这将使任务栏图标正确。

If you use either pyinstaller or py2exe (I prefer the former), when compiling it can set the applications icon - which will make the taskbar icon correct.

如果使用 pyinstaller ,你需要在specfile中设置图标:

If using pyinstaller, you'll want to set the icon as such in the specfile:

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.datas,
          name=os.path.join('..\\path\\to\\output', 'AppName.exe'),
          icon='C:\\abs\\path\\to\\icon\\icon.ico',
          debug=False,
          strip=False,
          upx=False,
          console=False )

icon =。 .. 行设置任务栏ic on。

The icon=... line sets the taskbar icon.

其余的python代码都没问题。

The rest of your python code is fine as is.

这篇关于任务栏的wxpython图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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