]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/viewer_basics.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / demo / viewer_basics.py
1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 # o No idea what this does.
5 #
6
7 import wx
8 import wx.lib.vtk as vtk
9
10 #---------------------------------------------------------------------------
11 class VtkFrame(wx.Frame):
12 """
13 Simple example VTK window that contains a cone.
14 """
15 def __init__(self, parent, id, title):
16 wx.Frame.__init__(self, parent, id, title, size=(450, 300))
17 win = vtk.VTKRenderWindow(self, -1)
18
19 renWin = win.GetRenderWindow()
20
21 ren = vtk.vtkRenderer()
22 renWin.AddRenderer(ren)
23 cone = vtk.vtkConeSource()
24 coneMapper = vtk.vtkPolyDataMapper()
25 coneMapper.SetInput(cone.GetOutput())
26 coneActor = vtk.vtkActor()
27 coneActor.SetMapper(coneMapper)
28 ren.AddActor(coneActor)
29
30 #---------------------------------------------------------------------------
31 # Using new event binder
32 wx_EVT_ADD_CONE = wx.NewEventType()
33 EVT_ADD_CONE = wx.PyEventBinder(wx_EVT_ADD_CONE, 1)
34
35 class AddCone(wx.PyEvent):
36 def __init__(self):
37 wx.PyEvent.__init__(self)
38 self.SetEventType(wx_EVT_ADD_CONE)
39
40
41 class HiddenCatcher(wx.Frame):
42 """
43 The "catcher" frame in the second thread.
44 It is invisible. It's only job is to receive
45 Events from the main thread, and create
46 the appropriate windows.
47 """
48 def __init__(self):
49 wx.Frame.__init__(self, None, -1, '')
50 self.Bind(EVT_ADD_CONE, self.AddCone)
51
52 def AddCone(self,evt):
53 add_cone()
54
55
56 #---------------------------------------------------------------------------
57
58 class SecondThreadApp(wx.App):
59 """
60 wxApp that lives in the second thread.
61 """
62 def OnInit(self):
63 catcher = HiddenCatcher()
64 #self.SetTopWindow(catcher)
65 self.catcher = catcher
66 return True
67
68 #---------------------------------------------------------------------------
69
70 def add_cone():
71 frame = VtkFrame(None, -1, "Cone")
72 frame.Show(True)
73