Skip to content

Commit

Permalink
Add PySide2 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Levi Dean <leviodean@gmail.com>
  • Loading branch information
LODean committed Feb 12, 2025
1 parent 9dd45f3 commit ab20030
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions picamera2/previews/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def __getattr__(name: str):
return _get_qpicamera2(_QT_BINDING.PyQt5)
elif name == 'Q6Picamera2':
return _get_qpicamera2(_QT_BINDING.PyQt6)
elif name == 'QSide2Picamera2':
return _get_qpicamera2(_QT_BINDING.PySide2)
elif name == 'QSide6Picamera2':
return _get_qpicamera2(_QT_BINDING.PySide6)
# OpenGL accelerated Qt widgets
elif name == 'QGlPicamera2':
return _get_qglpicamera2(_QT_BINDING.PyQt5)
elif name == 'QGl6Picamera2':
return _get_qglpicamera2(_QT_BINDING.PyQt6)
elif name == 'QGlSide2Picamera2':
return _get_qglpicamera2(_QT_BINDING.PySide2)
elif name == 'QGlSide6Picamera2':
return _get_qglpicamera2(_QT_BINDING.PySide6)
raise AttributeError(f"qt has no attribute '{name}'")
3 changes: 2 additions & 1 deletion picamera2/previews/qt_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class _QT_BINDING(Enum):
PyQt5 = 'PyQt5'
PyQt6 = 'PyQt6'
PySide2 = 'PySide2'
PySide6 = 'PySide6'


Expand All @@ -32,7 +33,7 @@ def _get_qt_modules(qt_module: _QT_BINDING) -> tuple[ModuleType, ModuleType, Mod
QtGuiModule = importlib.import_module('.QtGui', package=qt_module.value)
QtWidgetsModule = importlib.import_module('.QtWidgets', package=qt_module.value)

if qt_module == _QT_BINDING.PySide6:
if qt_module in [_QT_BINDING.PySide2, _QT_BINDING.PySide6]:
QtCoreModule.pyqtSignal = QtCoreModule.Signal
QtCoreModule.pyqtSlot = QtCoreModule.Slot

Expand Down

0 comments on commit ab20030

Please sign in to comment.