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

Error with ``QVTKRenderWindowInteractor‘’ #796

Closed
nil-is-lin opened this issue Jul 18, 2020 · 2 comments
Closed

Error with ``QVTKRenderWindowInteractor‘’ #796

nil-is-lin opened this issue Jul 18, 2020 · 2 comments

Comments

@nil-is-lin
Copy link

nil-is-lin commented Jul 18, 2020

I got the error when test the following code
`using PyCall

sys = pyimport("sys")
pygui(:qt)
PyCall.eventloops[:qt] = PyCall.qt_eventloop("PySide2", 50e-3)
QtWidgets = pyimport("PySide2.QtWidgets")
QtCore = pyimport("PySide2.QtCore")
QtGui = pyimport("PySide2.QtGui")
qvtk_window = pyimport("vtk.qt.QVTKRenderWindowInteractor")
vtk = pyimport("vtk")
pv = pyimport("pyvista")

app = QtWidgets.QApplication(sys.argv)
main_window = QtWidgets.QMainWindow()

frame = QtWidgets.QFrame()
vtk_widget = qvtk_window.QVTKRenderWindowInteractor(frame)
the last line(vtk_widget = qvtk_window.QVTKRenderWindowInteractor(frame)) throw ERROR: PyError ($(Expr(:escape, :(ccall(#= C:\Users***.julia\packages\PyCall\zqDXB\src\pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError("QWidget(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'PySide2.QtWidgets.QFrame'")
File "D:\Python\Python37\lib\site-packages\vtkmodules\qt\QVTKRenderWindowInteractor.py", line 260, in init
QWidget.init(self, parent, wflags | Qt.MSWindowsOwnDC)However, the origin python code is work well,import sys
import vtk
from PySide2 import QtCore, QtGui, QtWidgets
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

app = QtWidgets.QApplication(sys.argv)

window = QtWidgets.QMainWindow()
frame = QtWidgets.QFrame()
vl = QtWidgets.QVBoxLayout()
vtkWidget = QVTKRenderWindowInteractor(frame)
vl.addWidget(vtkWidget)
ren = vtk.vtkRenderer()
vtkWidget.GetRenderWindow().AddRenderer(ren)
iren = vtkWidget.GetRenderWindow().GetInteractor()

Create source

source = vtk.vtkSphereSource()
source.SetCenter(0, 0, 0)
source.SetRadius(5.0)

Create a mapper

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())

Create an actor

actor = vtk.vtkActor()
actor.SetMapper(mapper)

ren.AddActor(actor)

ren.ResetCamera()

frame.setLayout(vl)
window.setCentralWidget(frame)

window.show()
iren.Initialize()

sys.exit(app.exec_())
`

The Code running environment is: Win 10 professional, Vtk version is 9.0.1.
Thanks by advance for any help :)

@nil-is-lin
Copy link
Author

I just found that it works if I comment
pygui(:qt) PyCall.eventloops[:qt] = PyCall.qt_eventloop("PySide2", 50e-3)
So should I comment them?

@stevengj
Copy link
Member

If you are running your own event loop, you shouldn't call pygui at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants