Skip to content

Error with ``QVTKRenderWindowInteractor‘’ #796

Closed
@nil-is-lin

Description

@nil-is-lin

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions