nexxT.QtMetaPackage module

This module provides a QT meta package such that we are able to write “from nexxT.Qt.QtWidgets import QWidget” and nexxT.Qt will serve as an alias for PySide6

It is loosly based on this tutorial: https://dev.to/dangerontheranger/dependency-injection-with-import-hooks-in-python-3-5hap

class nexxT.QtMetaPackage.QtFinder(loader)[source]

Bases: MetaPathFinder

The meta path finder which will be added to sys.meta_path

__init__(loader)[source]
find_spec(fullname, path, target=None)[source]

Attempt to locate the requested module

Parameters:
  • fullname – the fully-qualified name of the module,

  • path – set to __path__ for sub-modules/packages, or None otherwise.

  • target – can be a module object, but is unused here.

class nexxT.QtMetaPackage.QtLoader(prefix, qtlib)[source]

Bases: Loader

The actual loader which maps PySide modules to nexxT.Qt. The approach is similar to executing a from PySide6 import * statement in a real Qt.py module, but it is dynamically and prevents from loading unused QT modules, like QtMultimedia, etc.

__init__(prefix, qtlib)[source]

Constructor.

Parameters:
  • prefix – the prefix for the proxied library (e.g. nexxT.Qt)

  • qtlib – the PySide library to be used, must be PySide6

create_module(spec)[source]

Creates a new module according to spec. It will be empty initially and populated during exec_module(…).

Parameters:

spec – A ModuleSpec instance.

exec_module(module)[source]

This function is called after create_module and it populates the module’s namespace with the corresponding instances from PySideX.

provides(fullname)[source]

Checks whether the queried module can be provided by this laoder or not.

Parameters:

fullname – full-qualified module name.

nexxT.QtMetaPackage.setup()[source]