qts

The top level package exposes the basic functionality of the qts library.

qts.__version__: str = 'v0.1'

The qts version string.

Selecting a wrapper

A Qt wrapper must be chosen before leveraging the qts compatibility features. qts is notified of the choice by a call to qts.set_wrapper().

qts.set_wrapper(wrapper: qts._core.Wrapper)None[source]

Set the wrapper you want to back the Qt modules accessed through qts.

Raises

Supported wrappers

The objects representing the supported wrappers are directly available. Each is an instance of the qts.Wrapper class. The full list of supported wrappers is available as qts._core.supported_wrappers.

qts._core.pyqt_5_wrapper = Wrapper(family='PyQt', name='PyQt5', major_version=5, module_name='PyQt5')

The PyQt/Qt5 wrapper object.

qts._core.pyqt_6_wrapper = Wrapper(family='PyQt', name='PyQt6', major_version=6, module_name='PyQt6')

The PyQt/Qt6 wrapper object.

qts._core.pyside_5_wrapper = Wrapper(family='PySide', name='PySide2', major_version=5, module_name='PySide2')

The PySide/Qt5 wrapper object.

qts._core.pyside_6_wrapper = Wrapper(family='PySide', name='PySide6', major_version=6, module_name='PySide6')

The PySide/Qt6 wrapper object.

qts._core.supported_wrappers = [Wrapper(family='PyQt', name='PyQt5', major_version=5, module_name='PyQt5'), Wrapper(family='PyQt', name='PyQt6', major_version=6, module_name='PyQt6'), Wrapper(family='PySide', name='PySide2', major_version=5, module_name='PySide2'), Wrapper(family='PySide', name='PySide6', major_version=6, module_name='PySide6')]

A list of all the supported wrapper objects.

class qts.Wrapper(family: str, name: str, major_version: int, module_name: str)[source]

Bases: object

A representation of a specific wrapper that can be used to access a specific version of Qt.

family

The wrapper family. "PyQt" or "PySide".

name

The name of the specific wrapper, including the version number. Such as "PySide6".

major_version

The major version of the wrapped Qt library. Such as 6.

module_name

The name used to import the module. Such as "PySide6".

Available wrappers

Not all supported wrappers will be available in every case.

qts.available_wrapper(wrappers: Optional[Iterable[qts._core.Wrapper]] = None)qts._core.Wrapper[source]

Get the available wrapper when there is only one.

Returns

The wrapper object for the single available wrapper.

Raises
qts.available_wrappers(wrappers: Optional[Iterable[qts._core.Wrapper]] = None)Sequence[qts._core.Wrapper][source]

Get a sequence of the wrappers that are available for use. If wrappers is passed, only wrappers that are both available and in the passed iterable will be returned.

Returns

The wrappers that are installed and available for use.

qts.wrapper_by_name(name: str)qts._core.Wrapper[source]

Get a wrapper object by its name. The name is checked case insensitively.

Returns

The wrapper that goes by the passed name.

Present configuration

You can directly query the present wrapper object multiple ways. The wrapper object can be retrieved directly through qts.wrapper. In some cases it is more useful to simply check if a specific wrapper is selected. The qts.is_* values are helpful for this. In particular, mypy is able to understand booleans via the command line arguments --always-false and --always-true. The Command line interface can be used to help generate the relevant options to pass to mypy.

qts.wrapper: Optional[qts._core.Wrapper]

The presently active wrapper. None if no wrapper is set.

qts.is_pyqt_5_wrapper: bool = False

True if the PyQt/Qt5 wrapper is active.

qts.is_pyqt_6_wrapper: bool = False

True if the PyQt/Qt6 wrapper is active.

qts.is_pyside_5_wrapper: bool = True

True if the PySide/Qt5 wrapper is active.

qts.is_pyside_6_wrapper: bool = False

True if the PySide/Qt6 wrapper is active.

Exceptions

See Exceptions.