import sys
from PyQt5 import (QtWidgets, QtCore)
import vtk
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(603, 553)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.gridlayout = QtWidgets.QGridLayout(self.centralWidget)
self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralWidget)
class SimpleView(QtWidgets.QMainWindow):
def __init__(self, parent = None):
QtWidgets.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ren = vtk.vtkRenderer()
self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.ui.v
PyQt5 + VTK + Python实现
最新推荐文章于 2024-09-04 21:27:22 发布
该博客介绍了如何结合PyQt5和VTK库在Python中创建一个3D可视化窗口。通过设置Qt主窗口,创建QVTKRenderWindowInteractor组件,并利用vtkRenderer、vtkSphereSource、vtkPolyDataMapper和vtkActor等VTK组件,展示了一个简单的3D球体渲染实例。
摘要由CSDN通过智能技术生成