I have a PySide app which has an icon for the MainWindow
(a QMainWindow
instance). When I run the file normally, the icon is visible and everything is fine but when I create an exe with py2exe
, the icon does not appear. This happens with cx_freeze
also( so I don't think the problem's with py2exe
).
The app was designed using QtDesigner
and converted to python with pyside-uic
. I tried both using icons as a file and as a resource(qrc file) and both don't seem to work.
Any help or pointers would be appreciated.
Thanks.
Could it be related to Windows 7's taskbar icon handling?
See How to set application's taskbar icon in Windows 7 for an answer to that.
kochelmonster's solution works so long as you don't try and bundle the Qt dlls into library.zip or the exe. You also don't need to set a library path if you put the plugins in the base of the app directory.
I still wanted to bundle everything else so I excluded the qt dlls and added them manually. My setup.py looks something like this:
If your project uses additional Qt dlls you will have to exclude and manually add them as well. If you need to load something other than an .ico image you'll also need to add the correct plugin.
I had the same problem. After some investigation I found a solution: (Macke had the right idea)
cx_freeze
does not copy thePyQt
plugins directory, which contains theico
image reader. Here are the steps:setup.py
copy thePyQt4
plugins directory to your distributionYou must include "qico4.dll" manually in your release folder. Insert this in your setup.py:
I'm assuming it works with a bmp, but not a png/jpg? If so, it's likely that the image format plugins don't load properly.
I'd guess setting up a qt.conf file in the installed application's directory and making sure plugin-dll's go to /plugins/imageformats/ will make things work better.