Window Icon of Exe in PyQt4

久未见 提交于 2019-12-05 03:06:50

The problem is that py2exe doesn't include the qt icon reader plugin. You need to tell it to include it with the data_files parameter. Something along these lines:

setup(windows=[{"script":script_path,
                "icon_resources":[(1, icon_path)]}], 
      data_files = [
            ('imageformats', [
              r'C:\Python26\Lib\site-packages\PyQt4\plugins\imageformats\qico4.dll'
              ])],
      options={"py2exe":{"packages":["gzip"], 
                         "includes":["sip"]}})

I believe you need to reference the .ico file directly from the EXE or DLL that you are creating with py2exe. You seem to have the setup.py script correct, so take a look at: http://www.py2exe.org/index.cgi/CustomIcons. There is an example for wxWidgets, but you could try to adapt it to Qt.

I would suggest you to create a file called YourApp.rc, add up the following line :

IDI_ICON1   ICON    DISCARDABLE "res/icons/app_icon.ico"

Then in your .PRO file, add up the following lines :

win32{
RC_FILE = YourApp.rc
}

It should fix your problem !

I had the same issue. For some reason it worked just fine with a image.png file & not an image.ico file. No clue why. But i converted the ico to png & it worked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!