]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxVTKRenderWindow.py
forgot to add the image with binary flags
[wxWidgets.git] / utils / wxPython / demo / wxVTKRenderWindow.py
1
2 from wxPython.wx import *
3 try:
4 from wxPython.lib import vtk
5 haveVTK = true
6 except ImportError:
7 haveVTK = false
8
9 #----------------------------------------------------------------------
10
11 def runTest(frame, nb, log):
12 if haveVTK:
13 win = vtk.wxVTKRenderWindow(nb, -1)
14
15 # Get the render window
16 renWin = win.GetRenderWindow()
17
18 # Next, do the VTK stuff
19 ren = vtk.vtkRenderer()
20 renWin.AddRenderer(ren)
21 cone = vtk.vtkConeSource()
22 cone.SetResolution(80)
23 coneMapper = vtk.vtkPolyDataMapper()
24 coneMapper.SetInput(cone.GetOutput())
25 coneActor = vtk.vtkActor()
26 coneActor.SetMapper(coneMapper)
27 ren.AddActor(coneActor)
28 coneMapper.GetLookupTable().Build()
29
30 # Create a scalar bar
31 scalarBar = vtk.vtkScalarBarActor()
32 scalarBar.SetLookupTable(coneMapper.GetLookupTable())
33 scalarBar.SetTitle("Temperature")
34 scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
35 scalarBar.GetPositionCoordinate().SetValue(0.1, 0.01)
36 scalarBar.SetOrientationToHorizontal()
37 scalarBar.SetWidth(0.8)
38 scalarBar.SetHeight(0.17)
39 ren.AddActor2D(scalarBar)
40
41 return win
42
43
44 else:
45 wxMessageBox("Unable to import VTK, which is a required component "
46 "of this demo. You need to download and install the "
47 "Python extension module for VTK from http://www.kitware.com/",
48 "Import Error")
49 return None
50
51 #----------------------------------------------------------------------
52
53
54 overview = """\
55 wxVTKRenderWindow is a wrapper around the vtkRenderWindow from the
56 VTK Visualization Toolkit. The VTK Python extensions are required,
57 they can be obtained from http://www.kitware.com/ where you can also
58 find some nifty pictures and stuff.
59
60 """