Commit c1cce50d authored by Tobias Hänel's avatar Tobias Hänel
Browse files

Add support for PySide2

Previously QVTKRenderWindowInteractor only supported PyQt5, PyQt4 and
PySide. Support for PySide2 was missing. This fixes issue #17403.
parent 118b08de
......@@ -38,6 +38,9 @@ Changes by Alex Tsui, Apr. 2015
Changes by Fabian Wenzel, Jan. 2016
Support for Python3
Changes by Tobias Hänel, Sep. 2018
Support for PySide2
# Check whether a specific PyQt implementation was chosen
......@@ -63,6 +66,10 @@ if PyQtImpl is None:
import PyQt5
PyQtImpl = "PyQt5"
except ImportError:
import PySide2
PyQtImpl = "PySide2"
except ImportError:
import PyQt4
......@@ -86,6 +93,18 @@ if PyQtImpl == "PyQt5":
from PyQt5.QtCore import QObject
from PyQt5.QtCore import QSize
from PyQt5.QtCore import QEvent
elif PyQtImpl == "PySide2":
if QVTKRWIBase == "QGLWidget":
from PySide2.QtOpenGL import QGLWidget
from PySide2.QtWidgets import QWidget
from PySide2.QtWidgets import QSizePolicy
from PySide2.QtWidgets import QApplication
from PySide2.QtGui import QCursor
from PySide2.QtCore import Qt
from PySide2.QtCore import QTimer
from PySide2.QtCore import QObject
from PySide2.QtCore import QSize
from PySide2.QtCore import QEvent
elif PyQtImpl == "PyQt4":
if QVTKRWIBase == "QGLWidget":
from PyQt4.QtOpenGL import QGLWidget
......@@ -382,7 +401,7 @@ class QVTKRenderWindowInteractor(QVTKRWIBaseClass):
def _getPixelRatio():
if PyQtImpl == "PyQt5":
if PyQtImpl in ["PyQt5", "PySide2"]:
# Source:
pos = QCursor.pos()
for screen in QApplication.screens():
......@@ -25,7 +25,7 @@ import sys
PyQtImpl = None
# Has an implementation has been imported yet?
for impl in ["PyQt5", "PyQt4", "PySide"]:
for impl in ["PyQt5", "PySide2", "PyQt4", "PySide"]:
if impl in sys.modules:
PyQtImpl = impl
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment