How to include icons in application when using Pyinstaller 2.0 ,PySide 1.1.2 Bindings and Qt 4.8

送分小仙女□ 提交于 2019-12-05 16:30:24

Ok, final answer, it turns out that Qt needs the following file qico4.dll might be different for Qt5, when making your GUI in QtDesigner it automatically loads all the plugins it needs including the above image plug in, however when converting the file into a python script it does not include it unless you add the following code in your script

#:Loads the qico plug-in lets you use .ico icons
QPlugin = QPluginLoader("qico4.dll")

The text below might help others in different situations

This is a partial answer to my own question I would like to thank Blender up above, the short answer is you have to convert your icons from .ico into .png files, the problem is that you have to do the whole process of making your application again, these are the steps that I took I first went into the folder where I had my icons and converted them froom .ico into .png icons, I used the tool I got here http://www.towofu.net/soft/e-aicon.php I found this in this site..I love stackoverflow..ahem

once your icons are converted to the .png format you must change your .qrc file where you have your icon information and updated with the new icon information, I advise doing it from scratch; once you have your new icons.qrc file you then open your .ui file in QtDesinger and erase all the instances of your old icons from it and then proceed to update them with the newly formatted icons using the icon/resource file.

After all of your icons have been updated, you save it and continue with the conversion workflow, i.e convert your 'your_file.ui' to 'newly_converted_file.py' using the pyside-uic.exe converter.

Next convert your 'icons.qrc' file into a 'icons_rc.py' using the pyside-rcc.exe command

at the end of this process you should only need your icons folder with your .png icons your icons_rc.py file and your application script.

After that you can continue to use the Pyinstaller-2.0 as per the manual..

As I've said it is a partial answer because it works, however if someone else could tell me or explain to me how to make it work with my original .ico files then I suspect I would not have to go trough the whole process again

Upon more research this page was especially helpful http://qt-project.org/forums/viewthread/17342

so I went into my Qt4.8 folder and did a search for qico4.dll and made a copy of it in the folder where my script is located and the application ran perfectly, If I can find a way to include it inside my script then I think I will have a complete answer, the problem seems to be with Qt and not Pyinstaller, it seems that it needs to be aware of the dll in order to process .ico files

I ran into the same problem as you. All the icons would seem to be missing when after pyinstaller created my executable (pyinstaller version 2.1 and PySide 1.2.1). However one of .png was displayed.

Therefore a possible workaround would be using .png instead of .ico for you icons in the PySide, and it will work on both sides (python and executable).

As an example:

QPushButton(QIcon("./icons/clear.png"),' &Clear',self.app_wgt)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!