]>
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
)
24 #---------------------------------------------------------------------------
25 wxEVT_ADD_CONE
= 25015
27 def EVT_ADD_CONE(win
, func
):
28 win
.Connect(-1, -1, wxEVT_ADD_CONE
, func
)
31 class AddCone(wxPyEvent
):
33 wxPyEvent
.__init
__(self
)
34 self
.SetEventType(wxEVT_ADD_CONE
)
37 class HiddenCatcher(wxFrame
):
39 The "catcher" frame in the second thread.
40 It is invisible. It's only job is to receive
41 Events from the main thread, and create
42 the appropriate windows.
45 wxFrame
.__init
__(self
, None, -1, '')
46 EVT_ADD_CONE(self
, self
.AddCone
)
48 def AddCone(self
,evt
):
52 #---------------------------------------------------------------------------
54 class SecondThreadApp(wxApp
):
56 wxApp that lives in the second thread.
59 catcher
= HiddenCatcher()
60 #self.SetTopWindow(catcher)
64 #---------------------------------------------------------------------------
67 frame
= VtkFrame(None, -1, "Cone")