Packaging with Pyinstaller: PyQt4.QtGui.setStyle ignored?

主宰稳场 提交于 2019-12-09 19:46:56

问题


Question:

How do I set the PyQt style for my app using Pyinstaller on Ubuntu 14.04?

Details:

I have packaged a PyQt4/Python app using pyinstaller on Windows and it seems to work fine with no difference between the package and when running just in my IDE. I have tried to reproduce this process using Ubuntu 14.04 and I have some issues that I can't solve.

I can set the PyQt style when running in my IDE by using: app = QtGui.QApplication(sys.argv) app.setStyle('sgi') This is ignored during the build process, though. Everything else is working in the same way as the Windows build, but the packaged Ubuntu app looks very different to when it is run in the IDE on Ubuntu:

IDE:

Pyinstaller result:

I am building the app using:

james@james-PC:~$ pyinstaller --distpath /path/myApp/tmp --onedir /path/myApp/myApp.spec

I have run the app using Terminal to see if there is anything cropping up, but the only thing that appears is the following when the app first loads:

(myApp:8312): Gtk-WARNING **: Unable to locate theme engine in module_path: "murrine",

Googling the Gtk-WARNING there are a number of suggested solutions. I have tried each multiple times with no luck. From what I've read I'm not convinced that this is related to my PyQt setStyle problem either.

Just in case it is useful, the spec file that I am using is as follows:

# -*- mode: python -*-
block_cipher = None
added_files = [('some/file.txt','.')]
a = Analysis(['/path/myApp.py'],
    pathex=['/home/'],
    binaries=None,
    datas=added_files,
    hiddenimports=['numpy','os','sys','joblib.Parallel','joblib.delayed','scipy.signal.spectrogram','matplotlib','mplwidget','multiprocessing','matplotlib.pyplot','matplotlib.cm','platform','time','ctypes','matplotlib.gridspec','scipy.constants','tkinter','tkFileDialog','myGUI','scipy.interpolate.interp1d','itertools.combinations','pyfftw'],
    hookspath=[],
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_ciper)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_ciper)
exe = EXE(pyz, a.scripts, exclude_binaries=True, name='maApp', debug=False, strip=False, upx=True, console=True)
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, name='myApp')

Thanks in advance for any pointers or solutions.

来源:https://stackoverflow.com/questions/41111522/packaging-with-pyinstaller-pyqt4-qtgui-setstyle-ignored

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!