posted on: 2009-03-02 22:58:19
This a is PyQt4 example that implements the VTK toolkit and produces Cone.py
>At fist I found the classes a little tough to get around but in the end they were quite easy. I meantioned what I had to do to get my installation of VTK working Here which worked but it isn't great, I still have to run a bash script to set my environment variables, and when I changed directorys I had to recompile, every thing...ev...ery...thing.
This is a version of cone.py found at Using VTK Through Python
And I "ported" this to PyQt4, really the navigation of the packages is a little brutal.
#!/usr/bin/env python
from PyQt4 import QtGui,QtCore
from vtk.qt4 import QVTKRenderWindowInteractor
import vtk
import sys
class ConeWindow(QVTKRenderWindowInteractor.QVTKRenderWindowInteractor):
def __init__(self):
QVTKRenderWindowInteractor.QVTKRenderWindowInteractor.__init__(self,None)
self.render_window = self.GetRenderWindow()
self.render_window.SetSize(300,300)
self.vrenderer = vtk.vtkRenderer()
self.render_window.AddRenderer(self.vrenderer)
self.cone = vtk.vtkConeSource()
self.cone.SetResolution(8)
self.coneMapper = vtk.vtkPolyDataMapper()
self.coneMapper.SetInput(self.cone.GetOutput())
self.coneActor = vtk.vtkActor()
self.coneActor.SetMapper(self.coneMapper)
self.vrenderer.AddActor(self.coneActor)
if __name__=='__main__':
app = QtGui.QApplication(sys.argv)
widge = ConeWindow()
widge.show()
sys.exit(app.exec_())
and I will upload the .py file new_vtk.py
on to bigger and better things ...
Comments
None
2012-09-24 15:12:35
I get a grey window with no shapes, please help...:(