views:

205

answers:

1

To enable jpeg support in a PyQT application, you have to manually include the qjpeg4.dll.
It works fine when the dll and pyd file are not bundled together in the final exe. For example with py2exe you can do the following :

DATA=[('imageformats',['C:\\Python26/Lib/site-packages/PyQt4/plugins/imageformats/qjpeg4.dll'])]
setup(console=[{"script":"cycotic.py"}], 
    data_files = DATA,
    options={"py2exe":{
        "includes":["sip"],
        "excludes":MODULE_EXCLUDES,
        "bundle_files":3,
        "compressed":False,
        "xref":True}}, 
    zipfile=None)

However, if you do the same thing, and you bundle the dll in the exe (using "bundle_files":1), it fails with the following message :

QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)

QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)

QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)

QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::end: Painter not active, aborted
QPixmap::scaled: Pixmap is a null pixmap

How can I bundle the application properly ?

A: 

Try adding pyqt4 as a package to force py2exe to include everything from PyQT in your build, like this:

options={"py2exe":{
        "includes":["sip"],
        "excludes":MODULE_EXCLUDES,
        "packages":["PyQt4"],
        "bundle_files":1,
        "compressed":False,
        "xref":True}}
jcoon
Modified pyqt -> PyQt4 to have a valid package name, but it failed.Apparently PyQt4 does not like to be include this way. It fails with :error: compiling 'C:\Python26\lib\site-packages\PyQt4\uic\port_v3\proxy_base.py' failed SyntaxError: invalid syntax (proxy_base.py, line 4)
shodanex
That is a bug in proxy_base.py? add proxy_base to your Excludes and see if it builds
jcoon