-
Notifications
You must be signed in to change notification settings - Fork 19
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
QPainter::begin: Paint device returned engine == 0, type: 1 #196
QPainter::begin: Paint device returned engine == 0, type: 1 #196
Comments
This same issue first appeared in the |
@adeak @tkoyama010 @akaszynski @larsoner Do you have any idea on how to approach this one? FYI, this might be a great one to debug at SciPy this week in a sprint. |
@banesullivan @GuillaumeFavelier Also shamelessly pinging you for your help with the above issue as well 😆 |
Linking as well the VTK issue I posted for this: QPainter::begin: Paint device returned engine == 0, type: 1 #18606 |
@akaszynski @larsoner @adeak @tkoyama010 @banesullivan @GuillaumeFavelier Copying here as this affects us as well: An important note on differences between The key takeaway is this:
@wmvanvliet I suspect this is why switching back to @prabhuramachandran @larsoner After investigating, it looks like Since the |
@akaszynski @larsoner @adeak @tkoyama010 @banesullivan @GuillaumeFavelier See Problem when using QGLWidget #969 for more details (my troubleshooting steps), but in summary: If I add window_ = QtGui.QWindow.fromWinId(self.plotter.winId())
self.container = self.createWindowContainer(window_, self) to my
so the final MRE is now Final MREfrom __future__ import annotations
from pyvistaqt import MainWindow, QtInteractor
from qtpy import QtGui, QtWidgets
class Window(MainWindow):
def __init__(self, parent=None):
MainWindow.__init__(self, parent)
self.setWindowTitle('Example')
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().setSpacing(0)
self.plotter = QtInteractor()
self.plotter.add_axes()
window_ = QtGui.QWindow.fromWinId(self.plotter.winId())
self.container = self.createWindowContainer(window_, self)
self.setCentralWidget(self.container)
self.signal_close.connect(self.plotter.close)
format_ = QtGui.QSurfaceFormat()
format_.setMajorVersion(4)
format_.setMinorVersion(6)
format_.setDepthBufferSize(16)
QtGui.QSurfaceFormat.setDefaultFormat(format_)
app = QtWidgets.QApplication([])
window = Window()
window.show()
app.exec_() I'm unsure if there is a better way. I'm open to suggestions though. This and simply adding this check in if os.name == 'posix':
self.setAttribute(WidgetAttribute.WA_PaintOnScreen) solve 100% of the problems for me. |
Sorry for the delay in responding. All the maintainers have been focused on preparing tutorials for Scipy2022 for the past few days. Have you solved the problem, and we are waiting for your PullRequest. |
Sorry for the slow response, I was out for a bit. There have been a lot of messages about this, @adam-grant-hendry can you try to distill to what changes pyvistaqt needs to make? It seems like maybe it's just the |
@tkoyama010 @larsoner Yes, no problem. I purposefully left many comments since I can’t make the sprints.
The issue stems from two things:
To fix the errors from this:
window_ = QtGui.QWindow.fromWinId(WId)
self.container = self.createWindowContainer(window_, self) |
@adam-grant-hendry can you add a PR for this to pyvistaqt? Then we can see if CIs are happy. If they are, then a PR to vtk and then mayavi as well would be good -- the former because we (pyvistaqt) really want our .py file to just be a copy of the upstream vearsion, and the latter because it would be good to fix Mayavi as well! |
@larsoner Yes, but I might not be able to by the sprints (I’ll try though). I’m AFK right now. Otherwise, I can on Monday. One thing I would ask - if possible, at the sprints, please discuss with the CI’s any ramifications from using native widgets over alien widgets. There are performance costs to using native widgets. |
I assume you mean "maintainers" here... when I say "Then we can see if CIs are happy" I am anthopromorphizing the continuous integration / unit tests that we run, not talking about actual people :)
You mean the currently used |
Ya, my bad
No, we use
I mean consider all the important changes made when
I think it is mandatory for all of us updating and contributing to |
Sorry, I think you may have meant My point in requesting the docs be mulled over was that I don’t know if there’s a better way to achieve what I did or if continuing to use native widgets is okay. Trying to rewrite At first glance, from reading the Qt docs, it seems there may be performance benefits from a refactor. However, I’m not seasoned enough with the remainder of pyvista and mayavi to know if it’s worth the effort. |
@larsoner Sorry for my last two comments. I didn’t read your response clearly enough). I submitted a PR, but tests only passed for PyQt5 on my machine (Windows, Python 3.8). If you or other team members have time to get the other tests to pass, feel free to push directly to my branch. I put Also, I can’t declare We could look at refactoring for performance improvements when using |
@tkoyama010 No worries! I knew everyone was busy and I would be mostly AFK for the latter half of the week, so I purposefully left a lot of comments to help you and the team see my debugging process. I submitted a PR, but many tests are still not passing. If you and other team members have time to take a look during the sprints, please feel free to push directly to my branch. Thank you and @larsoner for all your help! You guys are amazing! |
@larsoner @tkoyama010 Please note that my "fix" only works when # QVTKRWIBase, base class for QVTKRenderWindowInteractor,
# can be altered by the user to "QGLWidget" or "QOpenGLWidget"
# in case of rendering errors (e.g. depth check problems,
# readGLBuffer warnings...)
QVTKRWIBase = "QWidget" and you can also set the python # PyQtImpl can be set by the user
PyQtImpl = None QVTKRenderWindowInteractor.py then pulls in the modified information # Check whether a specific PyQt implementation was chosen
try:
import vtkmodules.qt
PyQtImpl = vtkmodules.qt.PyQtImpl
except ImportError:
pass
# Check whether a specific QVTKRenderWindowInteractor base
# class was chosen, can be set to "QGLWidget" in
# PyQt implementation version lower than Qt6,
# or "QOpenGLWidget" in Pyside6 and PyQt6
QVTKRWIBase = "QWidget"
try:
import vtkmodules.qt
QVTKRWIBase = vtkmodules.qt.QVTKRWIBase
except ImportError:
pass This situation isn't ideal because if the user changes or updates versions of import vtkmodules.qt
vtkmodules.qt.PyQtImpl = 'PySide6'
vtkmodules.qt.QVTKRWIBase = 'QOpenGLWidget'
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor I think the above should be added to the ImportantFrom the What's New in Qt4, Even though the raster paint engine is the primary paint engine for A good reference w.r.t. using the How to decide between QVTKOpenGL{Native}Widget? We could try to implement them using the developer tips from here: |
@akaszynski @tkoyama010 @larsoner I have submitted MR 9443 on Thanks in advance! |
@adam-grant-hendry -- I am sorry I got COVID at SciPy the sprints were a washout for me and thereafter I had to travel a long way and am still a bit under the weather. What time I do have is taken up by the semester which is now in full swing. I will try and get to this either this weekend or the next. Thanks for your patience. |
No problem @prabhuramachandran . Thank you for your help! |
@banesullivan @GuillaumeFavelier If either of you can review MR 9443 on |
Discussed in #194
Originally posted by adam-grant-hendry July 8, 2022
When using
QtInteractor
(Windows 10 with PySide6)The error:
appears every time the screen is updated (even if
plotter.show()
is placed afterwindow.show()
.From the PySide6 QPaintEngine docs, the error is saying
Qt
thinks I am onX11
:QPaintEngine.X11 == 0
QPainEngine.Windows == 1
After debugging in VSCode with the following
launch.json
so the debugger goes into packages:I found the error happens when
rwi.py::QVTKRenderWindowInteractor.paintEngine()
is called in response to aPaint
event:I also noticed
pyvistaqt.rwi::QVTKRenderWindowInteractor.__init__()
sets widget attributeFrom the PySide6 docs, this flag is only supported on
X11
and requires returning NULL (None
) frompaintEngine
:Hence, an alternative is needed for non-
X11
systems (Windows
,Mac
) runningPySide
for OpenGL to be possible.The text was updated successfully, but these errors were encountered: