【问题标题】:SVG images dont appear after compiling PyQt4 python code with py2exe使用 py2exe 编译 PyQt4 python 代码后,SVG 图像不会出现
【发布时间】:2010-08-08 15:19:03
【问题描述】:

我使用 svg 图像作为图标编写了 python 应用程序。

QtGui.QIcon(':icons/icon.svg')  <- just like this

它可以在我的通勤机上运行,​​但是用 py2exe 编译并在另一台计算机上运行后,没有图标。 如果我尝试例如bmp 格式,一切正常。所以我认为这可能是一些图书馆问题。 我不知道 PyQt4 用于 svg 图形的什么。

在我写的 setup.py 文件中

dllList = ('mfc90.dll','msvcp90.dll','qtnetwork.pyd','qtxmlpatterns4.dll', 'qsvg4.dll', 'qsvgd4.dll')
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
    if os.path.basename(pathname).lower() in dllList:
        return 0
    return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

setup(windows=[{"script" : "myApp.py"}], options={"py2exe" : {"includes" : ["sip", "PyQt4.QtNetwork", "PyQt4.QtWebKit", "PyQt4.QtSvg" ]}})

myApp.exe 目录中还包含 imageformats 文件夹(带有 qvg4.dll 等)

那么如何解决这个问题呢?

谢谢, 贾雷克

【问题讨论】:

    标签: python svg pyqt4 py2exe


    【解决方案1】:

    使用的插件(Qt 4.6)是:

    • 插件/
      • 图标引擎/
        • qsvgicon4.dll

    正如 Ivo 解释的那样,您仍然需要 qt.conf。

    【讨论】:

    • 如果您愿意放弃 plugins 文件夹(将 iconengines 放在顶级应用程序文件夹中),那么您不需要 qt.conf。
    【解决方案2】:

    您必须在应用程序的主安装目录(实际上是应用程序的工作目录)中添加qt.conf,其中包含:

    [Paths]
    Plugins = <directory containing the image plugins directory>
    

    所以目录布局是:

    • app.exe
    • qt.conf
    • 插件/
      • 图像格式/
        • qsvg4.dll

    然后在这种情况下,qt.conf 中的目录是plugins

    【讨论】:

      【解决方案3】:

      qsvg 插件需要QtXml。将"PyQt4.QtXml" 添加到您的包含中。

      另见library dependencies in Qt

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-05-04
        • 1970-01-01
        • 1970-01-01
        • 2018-04-26
        • 1970-01-01
        • 1970-01-01
        • 2010-10-26
        相关资源
        最近更新 更多