Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(qvtkinteractor): fix native widget drawing #200

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 21 additions & 60 deletions pyvistaqt/rwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
Changes by Eric Larson and Guillaume Favelier, Apr. 2022
Support for PyQt6
"""
import os

# Check whether a specific PyQt implementation was chosen
try:
Expand Down Expand Up @@ -117,79 +118,37 @@
if PyQtImpl == "PyQt6":
if QVTKRWIBase == "QOpenGLWidget":
from PyQt6.QtOpenGLWidgets import QOpenGLWidget
from PyQt6.QtWidgets import QWidget
from PyQt6.QtWidgets import QSizePolicy
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QMainWindow
from PyQt6.QtCore import QEvent, QObject, QSize, Qt, QTimer
from PyQt6.QtGui import QCursor
from PyQt6.QtCore import Qt
from PyQt6.QtCore import QTimer
from PyQt6.QtCore import QObject
from PyQt6.QtCore import QSize
from PyQt6.QtCore import QEvent
from PyQt6.QtWidgets import QApplication, QMainWindow, QSizePolicy, QWidget
elif PyQtImpl == "PySide6":
if QVTKRWIBase == "QOpenGLWidget":
from PySide6.QtOpenGLWidgets import QOpenGLWidget
from PySide6.QtWidgets import QWidget
from PySide6.QtWidgets import QSizePolicy
from PySide6.QtWidgets import QApplication
from PySide6.QtWidgets import QMainWindow
from PySide6.QtCore import QEvent, QObject, QSize, Qt, QTimer
from PySide6.QtGui import QCursor
from PySide6.QtCore import Qt
from PySide6.QtCore import QTimer
from PySide6.QtCore import QObject
from PySide6.QtCore import QSize
from PySide6.QtCore import QEvent
from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy, QWidget
elif PyQtImpl == "PyQt5":
if QVTKRWIBase == "QGLWidget":
from PyQt5.QtOpenGL import QGLWidget
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QSizePolicy
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtCore import QEvent, QObject, QSize, Qt, QTimer
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import Qt
from PyQt5.QtCore import QTimer
from PyQt5.QtCore import QObject
from PyQt5.QtCore import QSize
from PyQt5.QtCore import QEvent
from PyQt5.QtWidgets import QApplication, QMainWindow, QSizePolicy, QWidget
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.QtWidgets import QMainWindow
from PySide2.QtCore import QEvent, QObject, QSize, Qt, QTimer
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
from PySide2.QtWidgets import QApplication, QMainWindow, QSizePolicy, QWidget
elif PyQtImpl == "PyQt4":
if QVTKRWIBase == "QGLWidget":
from PyQt4.QtOpenGL import QGLWidget
from PyQt4.QtGui import QWidget
from PyQt4.QtGui import QSizePolicy
from PyQt4.QtGui import QApplication
from PyQt4.QtGui import QMainWindow
from PyQt4.QtCore import Qt
from PyQt4.QtCore import QTimer
from PyQt4.QtCore import QObject
from PyQt4.QtCore import QSize
from PyQt4.QtCore import QEvent
from PyQt4.QtCore import QEvent, QObject, QSize, Qt, QTimer
from PyQt4.QtGui import QApplication, QMainWindow, QSizePolicy, QWidget
elif PyQtImpl == "PySide":
if QVTKRWIBase == "QGLWidget":
from PySide.QtOpenGL import QGLWidget
from PySide.QtGui import QWidget
from PySide.QtGui import QSizePolicy
from PySide.QtGui import QApplication
from PySide.QtGui import QMainWindow
from PySide.QtCore import Qt
from PySide.QtCore import QTimer
from PySide.QtCore import QObject
from PySide.QtCore import QSize
from PySide.QtCore import QEvent
from PySide.QtCore import QEvent, QObject, QSize, Qt, QTimer
from PySide.QtGui import QApplication, QMainWindow, QSizePolicy, QWidget
else:
raise ImportError("Unknown PyQt implementation " + repr(PyQtImpl))

Expand Down Expand Up @@ -362,7 +321,7 @@ def __init__(self, parent=None, **kw):

# Python2
if type(WId).__name__ == 'PyCObject':
from ctypes import pythonapi, c_void_p, py_object
from ctypes import c_void_p, py_object, pythonapi

pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]
Expand All @@ -371,7 +330,7 @@ def __init__(self, parent=None, **kw):

# Python3
elif type(WId).__name__ == 'PyCapsule':
from ctypes import pythonapi, c_void_p, py_object, c_char_p
from ctypes import c_char_p, c_void_p, py_object, pythonapi

pythonapi.PyCapsule_GetName.restype = c_char_p
pythonapi.PyCapsule_GetName.argtypes = [py_object]
Expand All @@ -397,7 +356,8 @@ def __init__(self, parent=None, **kw):

# do all the necessary qt setup
self.setAttribute(WidgetAttribute.WA_OpaquePaintEvent)
self.setAttribute(WidgetAttribute.WA_PaintOnScreen)
if os.name == 'posix':
self.setAttribute(WidgetAttribute.WA_PaintOnScreen)
self.setMouseTracking(True) # get all mouse events
self.setFocusPolicy(FocusPolicy.WheelFocus)
self.setSizePolicy(QSizePolicy(SizePolicy.Expanding, SizePolicy.Expanding))
Expand Down Expand Up @@ -640,11 +600,12 @@ def Render(self):
def QVTKRenderWidgetConeExample(block=False):
"""A simple example that uses the QVTKRenderWindowInteractor class."""

from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer
import vtkmodules.vtkInteractionStyle

# load implementations for rendering and interaction factory classes
import vtkmodules.vtkRenderingOpenGL2
import vtkmodules.vtkInteractionStyle
from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer

# every QT app needs an app
app = QApplication.instance()
Expand Down
2 changes: 1 addition & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QtPy==2.1.0
Sphinx==5.0.2
sphinx-autobuild==2021.3.14
sphinx-copybutton==0.5.0
sphinx-notfound-page==0.8
sphinx-notfound-page==0.8.3
sphinx-rtd-theme==1.0.0
sphinxcontrib-napoleon==0.7
sphinxcontrib-websupport==1.2.4
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ scooby==0.5.12
flake8-black==0.3.3
flake8-isort==4.1.1
flake8-quotes==3.3.1
check-jsonschema==0.17.0
check-jsonschema==0.17.1
pre-commit==2.20.0
pre-commit-hooks==4.3.0
toml==0.10.2