PyQt/PySide - icon display

前端 未结 5 887
温柔的废话
温柔的废话 2020-12-30 10:30

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

5条回答
  •  梦谈多话
    2020-12-30 11:10

    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:

    from os.path import join
    
    _PYSIDEDIR = r'C:\Python27\Lib\site-packages\PySide'
    data_files =[('imageformats',[join(_PYSIDEDIR,'plugins\imageformats\qico4.dll')]),
                  ('.',[join(_PYSIDEDIR,'shiboken-python2.7.dll'),
                    join(_PYSIDEDIR,'QtCore4.dll'),
                    join(_PYSIDEDIR,'QtGui4.dll')])
                  ]
    setup(
        data_files=data_files,
        options={
            "py2exe":{
                "dll_excludes":['shiboken-python2.7.dll','QtCore4.dll','QtGui4.dll'],
                "bundle_files": 2
                ...
            }
        }
        ...
    )
    

    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.

提交回复
热议问题