SVG images dont appear after compiling PyQt4 python code with py2exe
I wrote python application using svg images as icons.
QtGui.QIcon(':icons/icon.svg') <- just like this
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.
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" ]}})
and also have imageformats folder (with qvg4.dll etc.) include开发者_开发百科d in myApp.exe directory
so how solve this problem?
thanks, jarek
The plugin used (Qt 4.6) is:
- plugins/
- iconengines/
- qsvgicon4.dll
- iconengines/
You still need qt.conf as Ivo explained.
You have to add a qt.conf
in your application's main installation directory (actually, the application's working directory), containing:
[Paths]
Plugins = <directory containing the image plugins directory>
So the directory layout is:
- app.exe
- qt.conf
- plugins/
- imageformats/
- qsvg4.dll
- imageformats/
And then in this case, the directory in qt.conf
is plugins
.
The qsvg
plugin requires QtXml
. Add "PyQt4.QtXml"
to your includes.
Also see library dependencies in Qt.
精彩评论