PyQt/PySide - icon display

前端 未结 5 888
温柔的废话
温柔的废话 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 10:58

    I had the same problem. After some investigation I found a solution: (Macke had the right idea)

    cx_freeze does not copy the PyQt plugins directory, which contains the ico image reader. Here are the steps:

    1. in setup.py copy the PyQt4 plugins directory to your distribution
    2. In your code write something like:
    application_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
    try:
       if sys.frozen:
            plugin_path = os.path.join(application_path, "qtplugins")
            app.addLibraryPath(plugin_path)
    except AttributeError:
        pass
    

提交回复
热议问题