python.utils package¶
Module contents¶
-
class
PyQt5Patcher
(*args, **kwargs)¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Patch remaining PyQt5 binding after Qt.py for PySide 1.
So yes, this patcher is used specifically after Qt.py patched most of PyQt5 bindings for PySide2.
It patches any remaining (Py)Qt5 bindings for PySide 1 since that’s what Shotgun still seems to mainly target as of May 2019.
Originally developed for Katana 3.1 for use in
tk-katana
:Katana 3.1 (PyQt5) | V Qt.py ^^^^^ | | Converts PyQt5 for PySide2 compatibility V PySide2Patcher (parent class from sgtk.util) ^^^^^^^^^^^^^^ | | Converts PySide2 for PySide 1 compatibility V PyQt5Patcher (that's me!) ^^^^^^^^^^^^ | | Converts any remaining PyQt5 for PySide 1 compatibility V KatanaEngine._define_qt_base ^^^^^^^^^^^^ | | Engine then exposes Qt bindings publicly through... V sgtk.platform.qt
-
classmethod
patch
(QtCore, QtGui, QtWidgets)¶ Patches QtCore, QtGui and QtWidgets
Parameters: - QtCore (module) – The QtCore module to patch.
- QtGui (module) – The QtGui module to patch.
- QtWidgets (module) – The QtWidgets module to patch.
-
classmethod
-
class
QtPyImporter
(qt=None, interface_version_requested=<sphinx.ext.autodoc.importer._MockObject object>)¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Extend QtImporter to use Qt.py.
Due to our patcher and Qt.py is local to tk_katana, this class is defined within this method to utilise modules imported by the engine’s
import_module()
.-
logger
¶ Standard Python logger for this Importer.
Type: logging.Logger
-
interface_version_requested
¶ Qt interface version requested during construction.
Type: int
-
base
¶ Mapping of Qt module, class and bindings names.
Type: dict[str]
- To Do:
- Refactor and upstream our attributes to
sgtk.util.qt_importer.QtImporter
.
-
base
Extends the parent property for older, Qt4 based interfaces.
The parent
QtImporter.base
seems to only be used exclusively wheninterface_version_requested
was Qt5.To make it useful for older Qt4 interfaces, the following common mappings are used instead for Qt4 as inspired by
tank.platform.engine.Engine._define_qt_base
:- “qt_core”, QtCore module to use
- “qt_gui”, QtGui module to use
- “wrapper”, Qt wrapper root module, e.g. PySide
- “dialog_base”, base class for Tank’s dialog factory.
Returns: Mapping of Qt module, class and bindings names. Return type: dict[str]
-
interface_version_requested
Get the interface version requested during construction.
Returns: Qt interface version requested during construction. Return type: int
-
logger
Get the Python logger
Returns: Standard Python logger for this importer. Return type: logging.Logger
-