pyinstaller不会加载应用程序图标

时间:2015-08-12 10:22:06

标签: python pyside py2exe pyinstaller

在我的应用程序中,我使用pyside-rcc生成qrc文件

<RCC>
  <qresource prefix="/" >
    <file>images/icon.jpg</file>
  </qresource>
</RCC>

使用此命令

pyside-rcc images.qrc -o images.py

然后我将它导入我的应用程序

import images

并设置应用图标

MainWindow.setWindowIcon(QtGui.QIcon(':/images/icon.jpg'))

当我用python

运行我的应用程序时
python app.py

我可以看到图标,没有任何问题

但是当我用pyinstaller编译它时

pyinstaller -i icon.co -w app.py

icon.co只是位于主目录中的另一个文件,用于设置exe图标。

exe有一个图标但是当我在标题或头部打开我的应用程序时,未加载图标images/icon.jpg,我也没有在工具栏中看到它。

enter image description here

我还尝试添加Tree('path\to\images'),但它没有用!

1 个答案:

答案 0 :(得分:0)

这非常简单......仅使用.png代替.ico.jpg来使其发挥作用。

这对.ico

也不起作用
QPlugin = QPluginLoader("qico4.dll")

这里提到了 How to include icons in application when using Pyinstaller 2.0 ,PySide 1.1.2 Bindings and Qt 4.8