开发者

py2exe and QSplashScreen

开发者 https://www.devze.com 2023-03-18 04:44 出处:网络
I want to add QSplashScreen to PyQT4 application. It works fine from Python, but when I create exe with py2exe, a splash image is invisible, the app wa开发者_运维问答its 2 sec and shows the main windo

I want to add QSplashScreen to PyQT4 application. It works fine from Python, but when I create exe with py2exe, a splash image is invisible, the app wa开发者_运维问答its 2 sec and shows the main window. What is wrong?

Application code:

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = QPixmap('images/splash.jpg')
    splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    time.sleep(2)

    myapp = Main()
    myapp.show()
    splash.finish(myapp)
    sys.exit(app.exec_())

setup.py:

#!/usr/bin/env python

from py2exe.build_exe import py2exe
from distutils.core import setup

setup(name='-',
      version='1.0',
      description='-',
      author='-',
      author_email='-',
      windows=[{"script": "main.py"}],
      data_files=[
                ('phonon_backend', [
                    'C:\Python26\Lib\site-packages\PyQt4\plugins\phonon_backend\phonon_ds94.dll'
                    ]),
                  'settings.yaml',
                  ('images', ['images/accept.png',
                              'images/splash.jpg',

                              ]),
                  'loader.png',
                  'licence.txt',
                  'about.txt',
                  ],
     )


PNG support comes by default, JPEG support is by a plugin which will need to be included in some way.

There was a thread recently on the PySide mailing list about this sort of thing with cx_freeze, starts at http://lists.pyside.org/pipermail/pyside/2010-December/001656.html. the solution will be approximately the same for PyQt4 and py2exe.

The final solution there was basically this:

Next to the produced .exe file, put qt.conf with this in it:

[Paths]
Plugins = plugins

(You could use a value other than "plugins", change the subdirectory name to match.)

Create a subdirectory plugins and in it another subdirectory imageformats. Copy qjpeg4.dll in here. It'll be in a path like C:\Python27\Lib\site-packages\PyQt4\plugins\imageformats.


It could be that you need QT's qjpeg4.dll. Try copying the following folder:

<python-dir>\Lib\site-packages\PyQt4\plugins\imageformats

into the folder containing the exe that py2exe creates.

That's where it'll be if you installed from the PyQt4 binary setup file from the Riverbank site. If you have a different install setup, hunt around.

0

精彩评论

暂无评论...
验证码 换一张
取 消