Advertisement
Guest User

VTK QT Animation

a guest
Jul 11th, 2018
109
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None
  1. import vtk
  2. from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
  3. from PyQt5 import Qt
  4.  
  5. message = "tick"
  6. def onTimerEvent(object, event):
  7.     global message
  8.     print(message)
  9.     if message == "tick":
  10.         message = "tock"
  11.     else:
  12.         message = "tick"
  13.  
  14. app        = Qt.QApplication([])
  15. mainWindow = Qt.QMainWindow()
  16. renderer = vtk.vtkRenderer()
  17. vtkWidget = QVTKRenderWindowInteractor(mainWindow)
  18. vtkWidget.GetRenderWindow().AddRenderer(renderer)
  19. mainWindow.setCentralWidget(vtkWidget)
  20.  
  21. vtkWidget.GetRenderWindow().GetInteractor().Initialize()
  22. timerId = vtkWidget.CreateRepeatingTimer(100)
  23. vtkWidget.AddObserver("TimerEvent", onTimerEvent)
  24.  
  25. mainWindow.show()
  26. app.exec_()
Advertisement
RAW Paste Data Copied
Advertisement