Supporting PySide and PyQt
For the purposes of this book, there are two differences between PySide and PyQt. We will use the qtshim.py
file to swap between the two depending on what is available. When the module is imported, it will choose between PySide and PyQt implementations, depending on what is available.
The qtshim.py
module contains four attributes:
The
QtCore
andQtGui
namespaces, pulled from the imported implementation.The
Signal
class, which just aliases thePySide.QtCore.Signal
orPyQt4.QtCore.pyqtSignal
class.The
wrapinstance
function which takes a pointer to a Qt object and returns the Qt object it points to. A pointer here is a long integer that refers to the memory location of the underlying Qt object. There is a significant difference between the implementation ofwrapinstance
between PySide and PyQt due to how their supporting libraries (shiboken
andsip
, respectively) work.
I'd suggest using a shim like qtshim
to allow easy switching between implementations, and also because...