]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/viewer_basics.py
1 from wxPython
.wx
import *
2 from wxPython
.lib
import vtk
4 #---------------------------------------------------------------------------
5 class VtkFrame(wxFrame
):
7 Simple example VTK window that contains a cone.
9 def __init__(self
, parent
, id, title
):
10 wxFrame
.__init
__(self
, parent
,id,title
, size
=(450, 300))
11 win
= vtk
.wxVTKRenderWindow(self
, -1)
13 renWin
= win
.GetRenderWindow()
15 ren
= vtk
.vtkRenderer()
16 renWin
.AddRenderer(ren
)
17 cone
= vtk
.vtkConeSource()
18 coneMapper
= vtk
.vtkPolyDataMapper()
19 coneMapper
.SetInput(cone
.GetOutput())
20 coneActor
= vtk
.vtkActor()
21 coneActor
.SetMapper(coneMapper
)
22 ren
.AddActor(coneActor
)
23 #---------------------------------------------------------------------------
24 wxEVT_ADD_CONE
= 25015
26 def EVT_ADD_CONE(win
, func
):
27 win
.Connect(-1, -1, wxEVT_ADD_CONE
, func
)
29 class AddCone(wxPyEvent
):
31 wxPyEvent
.__init
__(self
)
32 self
.SetEventType(wxEVT_ADD_CONE
)
34 class HiddenCatcher(wxFrame
):
36 The "catcher" frame in the second thread.
37 It is invisible. It's only job is to receive
38 Events from the main thread, and create
39 the appropriate windows.
42 wxFrame
.__init
__(self
, NULL
,-1,'')
43 EVT_ADD_CONE(self
, self
.AddCone
)
45 def AddCone(self
,evt
):
47 #---------------------------------------------------------------------------
48 class SecondThreadApp(wxApp
):
50 wxApp that lives in the second thread.
53 catcher
= HiddenCatcher()
54 #self.SetTopWindow(catcher)
57 #---------------------------------------------------------------------------
60 frame
= VtkFrame(NULL
, -1, "Cone")