Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Qt5.py enables you to write software that runs the same on both PySide2 and PyQt5.

See also

  • Qt.py - Like Qt5.py, with added support for PySide and PyQt4.

Goals

Write once, run in any binding.

Qt5.py is the younger brother to Qt.py and provides extended support for features unique to Qt 5, such as QtQml, QtMultimedia and QtWebAssembly.

GoalDescription
Support co-existenceQt5.py should not affect other bindings, not even Qt.py, running in the same interpreter session
Build for one, run with allCode written with Qt5.py should run identically on both PySide2 and PyQt5
Explicit is better than implicitDifferences between bindings should be visible to you.



Install

Qt5.py is a single file and can be either copy/pasted into your project, downloaded as-is, cloned as-is or installed via pip.

# From PyPI
$ pip install Qt5.py
  • Pro tip: The direct download and clone options refer to the latest commit of this project, which is typically beta. For the latest stable release, refer to any of the official releases
  • Pro top: Qt5.py supports vendoring



Usage

Use Qt5.py as you would use PySide2.

importosimportsysimporttempfilefromQt5importQtGui, QtQmlf=tempfile.NamedTemporaryFile("w", delete=False)
f.write("""\import QtQuick 2.4import QtQuick.Controls 1.4ApplicationWindow { title: "My App" width: 240 height: 180 visible: true Button { text: "Hello World" anchors.centerIn: parent }}""")
f.close()
app=QtGui.QGuiApplication(sys.argv)
engine=QtQml.QQmlApplicationEngine()
engine.load(f.name)
engine.quit.connect(app.quit)
app.exec_()
os.remove(f.name)

About

Minimal Python 2 & 3 shim around PySide2 and PyQt5

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages