简体   繁体   English

pyinstaller不会加载应用程序图标

[英]pyinstaller doesn't load app icon

In my Application i used pyside-rcc to generate qrc file 在我的应用程序中,我使用pyside-rcc生成qrc文件

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

using this command 使用此命令

pyside-rcc images.qrc -o images.py

then i imported it to my application 然后我将其导入到我的应用程序中

import images

and set the app icon 并设置应用程序图标

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

when i run my application with python 当我使用python运行我的应用程序时

python app.py

i can see the icon, nothing wrong with it 我可以看到该图标,它没有任何问题

but when i compile it with pyinstaller 但是当我用pyinstaller编译时

pyinstaller -i icon.co -w app.py

icon.co is only another file located in the main directory to set the exe icon. icon.co只是位于主目录中的另一个文件,用于设置exe图标。

the exe has an icon but when i open my application in the title or the head the icon images/icon.jpg isn't loaded, also i don't see it in the toolbar. 该exe有一个图标,但是当我在标题或标题中打开我的应用程序时,未加载图标images/icon.jpg ,在工具栏中也看不到它。

在此处输入图片说明

I also tried to add Tree('path\\to\\images') but it didn't work! 我也尝试添加Tree('path\\to\\images')但是没有用!

It was very trivial .... just used .png instead of .ico or .jpg to make it work. 这是非常琐碎的....只是使用.png而不是.ico.jpg使其起作用。

this didn't also work for .ico 这也不适用于.ico

QPlugin = QPluginLoader("qico4.dll")

which was mentioned here How to include icons in application when using Pyinstaller 2.0 ,PySide 1.1.2 Bindings and Qt 4.8 这里提到的是在使用Pyinstaller 2.0,PySide 1.1.2绑定和Qt 4.8时如何在应用程序中包含图标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM