qtpy
Provides an uniform layer to support PyQt5, PySide2, PyQt6, PySide6 with a single codebase
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
4 of 69 committers (5.8%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.7%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Provides an uniform layer to support PyQt5, PySide2, PyQt6, PySide6 with a single codebase
Basic Info
Statistics
- Stars: 1,049
- Watchers: 32
- Forks: 156
- Open Issues: 43
- Releases: 15
Topics
Metadata Files
README.md
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
Copyright © 2009– The Spyder Development Team
Description
QtPy is a small abstraction layer that lets you write applications using a single API call to either PyQt or PySide.
It provides support for PyQt5, PySide2, PyQt6 and PySide6 using the Qt5 layout (where the QtGui module has been split into QtGui and QtWidgets).
Basically, you can write your code as if you were using PyQt or PySide directly,
but import Qt modules from qtpy instead of PyQt5, PySide2, PyQt6 or PySide6.
Accordingly, when porting code between different Qt bindings (PyQt vs PySide) or Qt versions (Qt5 vs Qt6), QtPy makes this much more painless, and allows you to easily and incrementally transition between them. QtPy handles incompatibilities and differences between bindings or Qt versions for you while keeping your project running, so you can focus more on your own code and less on keeping track of supporting every Qt version and binding. Furthermore, when you do want to upgrade or support new bindings, it allows you to update your project module by module rather than all at once. You can check out examples of this approach in projects using QtPy, like git-cola.
Attribution and acknowledgments
This project is based on the pyqode.qt project and the spyderlib.qt module from the Spyder project, and also includes contributions adapted from qt-helpers, developed as part of the glue project.
Unlike pyqode.qt this is not a namespace package, so it is not tied
to a particular project or namespace.
License
This project is released under the MIT license.
Requirements
You need PyQt5, PySide2, PyQt6 or PySide6 installed in your system to make use
of QtPy. If several of these packages are found, PyQt5 is used by
default unless you set the QT_API environment variable.
QT_API can take the following values:
pyqt5(to use PyQt5).pyside2(to use PySide2).pyqt6(to use PyQt6).pyside6(to use PySide6).
Module aliases and constants
QtCore.pyqtSignal,QtCore.pyqtSlotandQtCore.pyqtProperty(available on PyQt5/6) are instead exposed asQtCore.Signal,QtCore.SlotandQtCore.Property, respectively, following the Qt5 module layout.The Qt version being used can be checked with
QtCore.__version__(instead ofQtCore.QT_VERSION_STR) as well as fromqtpy.QT_VERSION.For PyQt6 enums, unscoped enum access was added by promoting the enums of the
QtCore,QtGui,QtTestandQtWidgetsmodules.Compatibility is added between the
QtGuiandQtOpenGLmodules for theQOpenGL*classes.To check the current binding version, you can use
qtpy.PYSIDE_VERSIONfor PySide2/6 andqtpy.PYQT_VERSIONfor PyQt5/6. If the respective binding is not being used, the value of its attribute will beNone.To check the current selected binding, you can use
qtpy.API_NAMEThere are boolean values to check if Qt5/6, PyQt5/6 or PySide2/6 are being used:
qtpy.QT5,qtpy.QT6,qtpy.PYQT5,qtpy.PYQT6,qtpy.PYSIDE2andqtpy.PYSIDE6.Trueif currently being used,Falseotherwise.
Compat module
In the qtpy.compat module, you can find wrappers for QFileDialog static methods and SIP/Shiboken functions, such as:
QFileDialog.getExistingDirectorywrapped withqtpy.compat.getexistingdirectoryQFileDialog.getOpenFileNamewrapped withqtpy.compat.getopenfilenameQFileDialog.getOpenFileNameswrapped withqtpy.compat.getopenfilenamesQFileDialog.getSaveFileNamewrapped withqtpy.compat.getsavefilenamesip.isdeletedandshiboken.isValidwrapped withqtpy.compat.isalive
Installation
bash
pip install qtpy
or
bash
conda install qtpy
Type checker integration
Type checkers have no knowledge of installed packages, so these tools require additional configuration.
A Command Line Interface (CLI) is offered to help with usage of QtPy (to get MyPy and Pyright/Pylance args/configurations).
Mypy
The mypy-args command helps you to generate command line arguments for Mypy
that will enable it to process the QtPy source files with the same API
as QtPy itself would have selected.
If you run
bash
qtpy mypy-args
QtPy will output a string of Mypy CLI args that will reflect the currently selected Qt API. For example, in an environment where PyQt5 is installed and selected (or the default fallback, if no binding can be found in the environment), this would output the following:
text
--always-true=PYQT5 --always-false=PYSIDE2 --always-false=PYQT6 --always-false=PYSIDE6
Using Bash or a similar shell, this can be injected into the Mypy command line invocation as follows:
bash
mypy --package mypackage $(qtpy mypy-args)
Pyright/Pylance
In the case of Pyright, instead of runtime arguments, it is required to create a
config file for the project, called pyrightconfig.json or a pyright section
in pyproject.toml. See here
for reference. In order to set this configuration, QtPy offers the pyright-config
command for guidance.
If you run
bash
qtpy pyright-config
you will get the necessary configs to be included in your project files. If you don't have them, it is recommended to create the latter. For example, in an environment where PyQt5 is installed and selected (or the default fallback, if no binding can be found in the environment), this would output the following:
```text pyrightconfig.json: {"defineConstant": {"PYQT5": true, "PYSIDE2": false, "PYQT6": false, "PYSIDE6": false}}
pyproject.toml: [tool.pyright.defineConstant] PYQT5 = true PYSIDE2 = false PYQT6 = false PYSIDE6 = false ```
Note: These configurations are necessary for the correct usage of the default VSCode's type checking feature while using QtPy in your source code.
Testing matrix
Currently, QtPy runs tests for different bindings on Linux, Windows and macOS, using
Python 3.7 and 3.11, and installing those bindings with conda and pip. For the
PyQt bindings, we also check the installation of extra packages via pip.
Following this, the current test matrix looks something like this:
| | Python | 3.7 | | 3.11 | | |---------|-----------------|--------------------------------------------|------|--------------------|----------------------------| | OS | Binding / manager | conda | pip | conda | pip | | Linux | PyQt5 | 5.12 | 5.15 | 5.15 | 5.15 (with extras) | | | PyQt6 | skip (unavailable) | 6.3 | skip (unavailable) | 6.5 (with extras) | | | PySide2 | 5.13 | 5.12 | 5.15 | skip (no wheels available) | | | PySide6 | 6.4 | 6.3 | 6.5 | 6.5 | | Windows | PyQt5 | 5.9 | 5.15 | 5.15 | 5.15 (with extras) | | | PyQt6 | skip (unavailable) | 6.2 | skip (unavailable) | 6.5 (with extras) | | | PySide2 | 5.13 | 5.12 | 5.15 | skip (no wheels available) | | | PySide6 | skip (test hang with 6.4. 6.5 unavailable) | 6.2 | 6.5 | 6.5 | | MacOS | PyQt5 | 5.12 | 5.15 | 5.15 | 5.15 (with extras) | | | PyQt6 | skip (unavailable) | 6.3 | skip (unavailable) | 6.5 (with extras) | | | PySide2 | 5.13 | 5.12 | 5.15 | skip (no wheels available) | | | PySide6 | 6.4 | 6.3 | 6.5 | 6.5 |
Note: The mentioned extra packages for the PyQt bindings are the following:
PyQt3DandPyQt6-3DPyQtChartandPyQt6-ChartsPyQtDataVisualizationandPyQt6-DataVisualizationPyQtNetworkAuthandPyQt6-NetworkAuthPyQtPurchasingPyQtWebEngineandPyQt6-WebEngineQScintillaandPyQt6-QScintilla
Contributing
Everyone is welcome to contribute! See our Contributing guide for more details.
Sponsors
QtPy is funded thanks to the generous support of
and the donations we have received from our users around the world through Open Collective:
Owner
- Name: Spyder IDE
- Login: spyder-ide
- Kind: organization
- Website: https://www.spyder-ide.org/
- Repositories: 44
- Profile: https://github.com/spyder-ide
The Scientific Python Development Environment
GitHub Events
Total
- Create event: 2
- Release event: 2
- Issues event: 16
- Watch event: 74
- Delete event: 1
- Issue comment event: 41
- Push event: 10
- Pull request review event: 4
- Pull request event: 15
- Fork event: 5
Last Year
- Create event: 2
- Release event: 2
- Issues event: 16
- Watch event: 74
- Delete event: 1
- Issue comment event: 41
- Push event: 10
- Pull request review event: 4
- Pull request event: 15
- Fork event: 5
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Carlos Cordoba | c****2@g****m | 202 |
| dalthviz | d****0@u****o | 155 |
| Gonzalo Peña-Castellanos | g****a@g****m | 83 |
| C.A.M. Gerlach | C****h@G****M | 74 |
| David Kincaid | d****a@g****m | 57 |
| stsav012 | s****2@g****m | 54 |
| Thomas Robitaille | t****e@g****m | 51 |
| Julien Schueller | s****r@p****m | 17 |
| Rafael Laverde | l****1@g****m | 16 |
| Grzegorz Bokota | b****b@g****m | 12 |
| kumattau | k****u@g****m | 12 |
| pre-commit-ci[bot] | 6****] | 10 |
| David Aguilar | d****d@g****m | 9 |
| Joseph Martinot-Lagarde | c****e@g****m | 8 |
| Dhruv Govil | d****l@g****m | 7 |
| Dennis Goeries | d****s@x****u | 6 |
| René Fritze | r****e@w****e | 6 |
| Daniel Edler | d****r@w****e | 5 |
| Eric Larson | l****d@g****m | 5 |
| Talley Lambert | t****t@g****m | 5 |
| Matthieu Dartiailh | m****h@g****m | 4 |
| Tobias Gehring | t****g@f****k | 4 |
| Kyle Altendorf | s****a@f****t | 4 |
| Kurt Jacobson | k****r@g****m | 4 |
| Almar Klein | a****n@g****m | 4 |
| stonebig | s****4@g****m | 4 |
| Antonio Valentino | a****o@t****t | 3 |
| Damon Lynch | d****h@g****m | 3 |
| Julian Gilbey | j****t@d****t | 3 |
| Karthikeyan Singaravelan | t****i@g****m | 3 |
| and 39 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 92
- Total pull requests: 103
- Average time to close issues: 4 months
- Average time to close pull requests: 18 days
- Total issue authors: 53
- Total pull request authors: 28
- Average comments per issue: 3.05
- Average comments per pull request: 3.33
- Merged pull requests: 79
- Bot issues: 0
- Bot pull requests: 4
Past Year
- Issues: 14
- Pull requests: 18
- Average time to close issues: 19 days
- Average time to close pull requests: 3 days
- Issue authors: 10
- Pull request authors: 7
- Average comments per issue: 0.36
- Average comments per pull request: 1.94
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- dalthviz (15)
- StSav012 (11)
- yurivict (5)
- CAM-Gerlach (4)
- th3w1zard1 (3)
- adam-grant-hendry (2)
- ccordoba12 (2)
- owillebo (2)
- goanpeca (2)
- hannesdelbeke (2)
- ZeeD (2)
- dhkimmm (1)
- Savita-Panwar (1)
- oscargus (1)
- niklashenning (1)
Pull Request Authors
- dalthviz (21)
- StSav012 (18)
- CAM-Gerlach (11)
- jschueller (6)
- Czaki (4)
- hmaarrfk (4)
- zjp (4)
- pre-commit-ci[bot] (4)
- DaelonSuzuka (3)
- ccordoba12 (3)
- rear1019 (3)
- Bzero (2)
- PatriceJada (2)
- juliangilbey (2)
- davvid (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 18
-
Total downloads:
- pypi 6,617,073 last-month
- Total docker downloads: 1,063,133
-
Total dependent packages: 608
(may contain duplicates) -
Total dependent repositories: 7,742
(may contain duplicates) - Total versions: 151
- Total maintainers: 5
pypi.org: qtpy
Provides an abstraction layer on top of the various Qt bindings (PyQt5/6 and PySide2/6).
- Homepage: https://github.com/spyder-ide/qtpy
- Documentation: https://qtpy.readthedocs.io/
- License: MIT
-
Latest release: 2.4.3
published about 1 year ago
Rankings
Maintainers (3)
alpine-v3.18: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.3.1-r1
published almost 3 years ago
Rankings
Maintainers (1)
alpine-v3.18: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.3.1-r1
published almost 3 years ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/spyder-ide/qtpy
- Documentation: https://pkg.go.dev/github.com/spyder-ide/qtpy#section-documentation
- License: mit
-
Latest release: v2.4.3+incompatible
published about 1 year ago
Rankings
alpine-edge: py3-qtpy
QtPy: Abstraction layer for PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.3-r1
published 7 months ago
Rankings
Maintainers (1)
spack.io: py-qtpy
QtPy: Abtraction layer for PyQt5/PyQt4/PySide/PySide2
- Homepage: https://github.com/spyder-ide/qtpy
- License: []
-
Latest release: 1.11.2
published almost 4 years ago
Rankings
Maintainers (1)
alpine-v3.17: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.3.0-r1
published over 3 years ago
Rankings
Maintainers (1)
conda-forge.org: qtpy
QtPy is a small abstraction layer that lets you write applications using a single API call to either PyQt or PySide. It provides support for PyQt5, PyQt6, PySide6, PySide2 (using the Qt5 layout), so you can write your code as if you were using PyQt or PySide directly, but import Qt modules from qtpy instead of PyQt5, PySide2, PyQt6 or PySide6. Accordingly, when porting code between different Qt bindings (PyQt vs PySide) or Qt versions (Qt5 vs Qt6), QtPy makes this much more painless, and allows you to easily and incrementally transition between them. QtPy handles incompatibilities and differences between bindings or Qt versions for you while keeping your project running, so you can focus more on your own code and less on keeping track of supporting every Qt version and binding. Furthermore, when you do want to upgrade or support new bindings, it allows you to update your project module by module rather than all at once.
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.3.0
published over 3 years ago
Rankings
alpine-edge: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.3-r1
published 7 months ago
Rankings
Maintainers (1)
anaconda.org: qtpy
QtPy is a small abstraction layer that lets you write applications using a single api call to either PyQt or PySide.
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.1
published over 2 years ago
Rankings
alpine-v3.21: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.2-r0
published over 1 year ago
Rankings
Maintainers (1)
alpine-v3.22: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.3-r0
published about 1 year ago
Rankings
Maintainers (1)
alpine-v3.22: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.3-r0
published about 1 year ago
Rankings
Maintainers (1)
alpine-v3.20: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.1-r1
published almost 2 years ago
Rankings
Maintainers (1)
alpine-v3.19: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.1-r0
published over 2 years ago
Rankings
alpine-v3.20: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.1-r1
published almost 2 years ago
Rankings
Maintainers (1)
alpine-v3.21: py3-qtpy
QtPy: Abstraction layer for PyQt5/PySide2/PyQt6/PySide6
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.2-r0
published over 1 year ago
Rankings
Maintainers (1)
alpine-v3.19: py3-qtpy-pyc
Precompiled Python bytecode for py3-qtpy
- Homepage: https://github.com/spyder-ide/qtpy
- License: MIT
-
Latest release: 2.4.1-r0
published over 2 years ago
Rankings
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- conda-incubator/setup-miniconda v2 composite

