首页 > 代码库 > PyQt下VTK窗口创建

PyQt下VTK窗口创建

    # QVTKRenderWindowInteractor要求必须有初始化好的parent

    def CreateScene(self, parent):

        view = QVTKRenderWindowInteractor(parent)

        renderer = vtkRenderer()

        view.GetRenderWindow().AddRenderer(renderer)

        renderer.SetBackground(1,1, 1)

        view.GetRenderWindow().Render()

        actor = vtkContextActor()

        renderer.AddActor(actor)

        scene = actor.GetScene()

        scene.SetRenderer(renderer)

        layout = QVBoxLayout()

        layout.setContentsMargins(0,0,0,0)

        layout.addWidget(view)

        parent.setLayout(layout)

        self.view = view

        return scene