2010-08-08 34 views
4

我编写了使用svg图像作为图标的python应用程序。使用py2exe编译PyQt4 python代码后不会出现SVG图像

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

它在我的计算机上工作,但编译后与py2exe并在另一台计算机上运行,​​theres没有图标。 如果我尝试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" ]}}) 

,也有imageformats文件夹(与qvg4.dll等)列入目录MYAPP.EXE

因此,如何解决这个问题?

感谢, 亚雷克

回答

2

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

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

所以目录布局是:

  • app.exe
  • qt.conf
  • 插件/
    • imageformats/
      • qsvg4.dll

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

3

使用(QT 4.6)的插件是:

  • 插件/
    • iconengines/
      • qsvgicon4.dll

你仍然需要QT .conf如Ivo解释。

+0

如果您愿意放弃插件文件夹(将顶级应用程序文件夹中的图标引擎放置),那么您不需要qt.conf。 – Compholio 2017-04-21 00:15:51