]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/viewer_basics.py
Change demo to not try to drop the table when it thinks it is creating it for the...
[wxWidgets.git] / wxPython / demo / viewer_basics.py
CommitLineData
f6bcfd97
BP
1from wxPython.wx import *
2from wxPython.lib import vtk
3
4#---------------------------------------------------------------------------
5class VtkFrame(wxFrame):
6 """
7 Simple example VTK window that contains a cone.
8 """
9 def __init__(self, parent, id, title):
10 wxFrame.__init__(self, parent,id,title, size=(450, 300))
11 win = vtk.wxVTKRenderWindow(self, -1)
12
13 renWin = win.GetRenderWindow()
14
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#---------------------------------------------------------------------------
24wxEVT_ADD_CONE = 25015
25
26def EVT_ADD_CONE(win, func):
27 win.Connect(-1, -1, wxEVT_ADD_CONE, func)
28
29class AddCone(wxPyEvent):
30 def __init__(self):
31 wxPyEvent.__init__(self)
32 self.SetEventType(wxEVT_ADD_CONE)
33
34class HiddenCatcher(wxFrame):
35 """
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.
40 """
41 def __init__(self):
42 wxFrame.__init__(self, NULL,-1,'')
43 EVT_ADD_CONE(self, self.AddCone)
44
45 def AddCone(self,evt):
46 add_cone()
47#---------------------------------------------------------------------------
48class SecondThreadApp(wxApp):
49 """
50 wxApp that lives in the second thread.
51 """
52 def OnInit(self):
53 catcher = HiddenCatcher()
54 #self.SetTopWindow(catcher)
55 self.catcher =catcher
56 return true
57#---------------------------------------------------------------------------
58
59def add_cone():
60 frame = VtkFrame(NULL, -1, "Cone")
61 frame.Show(true)