[vtkusers] QVTKWidget in Python ?

chasank chasank at gmail.com
Mon Nov 28 10:33:55 EST 2011


What's the wrong with below script? It just shows a blank window, where is
the interactor window?
Can anyone help me?

import sys
from Nifti import Nifti
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import *
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
import vtk

class MainWindow(QtGui.QMainWindow):
  
  def __init__(self, parent = None):
    super(MainWindow, self).__init__(parent)        
    self.initUI()
    
  def initUI(self):

    widget = QVTKRenderWindowInteractor(self)
    widget.Initialize()
    widget.Start()
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtk.vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtk.vtkConeSource()
    cone.SetResolution(24)

    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInput(cone.GetOutput())

    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)
    ren.AddActor(coneActor)
    widget.show()
    
    layout = QVBoxLayout()
    layout.addWidget(widget)
    
    central = QWidget()
    central.setLayout(layout)
        
    self.setCentralWidget(central)    
    self.setWindowTitle('Example')
    self.show()


--
View this message in context: http://vtk.1045678.n5.nabble.com/QVTKWidget-in-Python-tp5024567p5029176.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list