]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/viewer_basics.py
fixed clip rect when logical coords != device ones
[wxWidgets.git] / wxPython / demo / viewer_basics.py
1 from wxPython.wx import *
2 from wxPython.lib import vtk
3
4 #---------------------------------------------------------------------------
5 class 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
24 #---------------------------------------------------------------------------
25 wxEVT_ADD_CONE = 25015
26
27 def EVT_ADD_CONE(win, func):
28 win.Connect(-1, -1, wxEVT_ADD_CONE, func)
29
30
31 class AddCone(wxPyEvent):
32 def __init__(self):
33 wxPyEvent.__init__(self)
34 self.SetEventType(wxEVT_ADD_CONE)
35
36
37 class HiddenCatcher(wxFrame):
38 """
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.
43 """
44 def __init__(self):
45 wxFrame.__init__(self, None, -1, '')
46 EVT_ADD_CONE(self, self.AddCone)
47
48 def AddCone(self,evt):
49 add_cone()
50
51
52 #---------------------------------------------------------------------------
53
54 class SecondThreadApp(wxApp):
55 """
56 wxApp that lives in the second thread.
57 """
58 def OnInit(self):
59 catcher = HiddenCatcher()
60 #self.SetTopWindow(catcher)
61 self.catcher =catcher
62 return true
63
64 #---------------------------------------------------------------------------
65
66 def add_cone():
67 frame = VtkFrame(None, -1, "Cone")
68 frame.Show(true)
69