Skip to content

Instantly share code, notes, and snippets.

@BoboTiG
Created October 3, 2020 14:56
Show Gist options
  • Save BoboTiG/91ece34579014cf60e63c1c756bea039 to your computer and use it in GitHub Desktop.
Save BoboTiG/91ece34579014cf60e63c1c756bea039 to your computer and use it in GitHub Desktop.
Sample PyInstaller spec file for PyQt5.QtWebEngineWidgets
# -*- mode: python -*-
# coding: utf-8
import io
import os
import os.path
import re
import sys
a = Analysis(
[os.path.join("t.py")],
)
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name="t",
console=False,
debug=False,
strip=False,
upx=False,
)
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name="t")
app = BUNDLE(
coll,
name="T.app",
bundle_identifier="local.t",
)
@BoboTiG
Copy link
Author

BoboTiG commented Oct 3, 2020

The t.py file (requires python -m pip install pyqt5==5.11.3):

import sys

def main():
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWebEngineWidgets import QWebEngineView

    url = 'https://github.com/pyinstaller/pyinstaller'
    app = QApplication(sys.argv)
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()
    sys.exit(app.exec_())

main()

Compile with python -m PyInstaller t.spec --noconfirm.

@BoboTiG
Copy link
Author

BoboTiG commented Oct 21, 2020

The PySide2 version (python -m pip install pyside2==5.11.2):

import sys

def main():
    from PySide2.QtWidgets import QApplication
    from PySide2.QtCore import QUrl
    from PySide2.QtWebEngineWidgets import QWebEngineView

    url = 'https://github.com/pyinstaller/pyinstaller'
    app = QApplication(sys.argv)
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()
    sys.exit(app.exec_())

main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment