""" A sort of minimal example of how to embed a rendering window into a qt application. """ print(__doc__) import sys from PyQt5 import Qt from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor import vtk from vtkplotter import * class MainWindow(Qt.QMainWindow): def __init__(self, parent=None): Qt.QMainWindow.__init__(self, parent) self.frame = Qt.QFrame() self.vl = Qt.QVBoxLayout() self.vtkWidget = QVTKRenderWindowInteractor(self.frame) self.vl.addWidget(self.vtkWidget) p = Plotter(qtWidget=self.vtkWidget, axes=4, bg='lightblue') a = Cube() a.flat() a.c('gold') p.add(a) p.show() # create renderer and add the actors # Manually create the silhouette actor and add to the renderer. dataset = a.GetMapper().GetInputAsDataSet() outline = vtk.vtkPolyDataSilhouette() outline.SetInputData(dataset) outline.SetEnableFeatureAngle(True) outline.SetCamera(p.renderers[0].GetActiveCamera()) outline.SetBorderEdges(True) outlineMapper = vtk.vtkPolyDataMapper() outlineMapper.SetInputConnection(outline.GetOutputPort()) actor = vtk.vtkActor() actor.SetMapper(outlineMapper) actor.GetProperty().SetColor(0, 0, 0) actor.GetProperty().SetLineWidth(4) p.renderers[0].AddActor(actor) # set-up the rest of the Qt window self.frame.setLayout(self.vl) self.setCentralWidget(self.frame) self.show() # <--- show the Qt Window if __name__ == "__main__": app = Qt.QApplication(sys.argv) window = MainWindow() app.exec_()