pyqt jpeg 支持不适用于捆绑形式 [英] pyqt jpeg support not working in bundled form

查看:68
本文介绍了pyqt jpeg 支持不适用于捆绑形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在 PyQT 应用程序中启用 jpeg 支持,您必须手动包含 qjpeg4.dll.
当 dll 和 pyd 文件未在最终 exe 中捆绑在一起时,它可以正常工作.例如使用 py2exe,您可以执行以下操作:

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)

但是,如果您执行相同的操作,并且将 dll 捆绑在 exe 中(使用 "bundle_files":1),则会失败并显示以下消息:

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 ?

推荐答案

我遇到了同样的问题,据我所知,py2exe 已经提供了线索:http://www.py2exe.org/index.cgi/Py2exeAndPyQt

I've got the same problem, As I know, py2exe has provided the clue: http://www.py2exe.org/index.cgi/Py2exeAndPyQt

内容如下:......所以你需要将文件夹 PyQt4\plugins\imageformats 复制到 \imageformats........ 这不适用于 bundle_files ....*这也适用于 bundle_files,但您需要从 bundle 中排除 Qt DLL(使用 dll_excludes 选项)并通过其他机制(例如 data_files)将它们添加到包含可执行文件的目录中.*

It reads: ......so you'll need to copy the folder PyQt4\plugins\imageformats to \imageformats. ....... This won't work with bundle_files on. ... *This will work with bundle_files as well, but you need to exclude the Qt DLLs from bundle (using the dll_excludes option) and add them to the directory with the executable through some other mechanism (such as data_files).*

以下是我的设置选项,如下所示:

following is my setup options, like this:

    zipfile=None,
    options = { "py2exe" :{
                           "compressed":1,
                           "includes": my_includes,                           
                           "packages": my_packages,
                           "optimize":2,
                           "bundle_files":1,
                           "dll_excludes":["QtCore4.dll","QtGui4.dll","QtNetwork4.dll"]
                           }}

所以 dist 文件夹包含这些文件(在我的例子中):

So the dist folder consists these files (in my case):

  • imageformats(文件夹,包含处理图像的qt插件dll)
  • QtCore4.dll
  • QtGui4.dll
  • QtNetwork4.dll
  • MyExeFile.exe
  • w9xpopen.exe

就这些

这篇关于pyqt jpeg 支持不适用于捆绑形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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