使用py2exe编译PyQt4 python代码后,SVG图像不出现 [英] SVG images dont appear after compiling PyQt4 python code with py2exe

查看:106
本文介绍了使用py2exe编译PyQt4 python代码后,SVG图像不出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wrote python application using svg images as icons.

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

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

it works on my comuter but after compiling it with py2exe and running on another computer, theres no icons. if i try e.g. bmp format, all works fine. so i think it could be some library problem. I don't know what PyQt4 uses for svg graphics.

在我写的setup.py文件中

in setup.py file i wrote

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等)

and also have imageformats folder (with qvg4.dll etc.) included in myApp.exe directory

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

so how solve this problem?

谢谢, jarek

推荐答案

使用的插件(Qt 4.6)是:

The plugin used (Qt 4.6) is:

  • 插件/
    • iconengines/
      • qsvgicon4.dll
      • plugins/
        • iconengines/
          • qsvgicon4.dll

          按照Ivo的说明,您仍然需要qt.conf.

          You still need qt.conf as Ivo explained.

          这篇关于使用py2exe编译PyQt4 python代码后,SVG图像不出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆