]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/viewer_basics.py
Added wx.lib.expando, a multi-line textctrl that exands as more lines
[wxWidgets.git] / wxPython / demo / viewer_basics.py
CommitLineData
8fa876ca
RD
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
7import wx
8import wx.lib.vtk as vtk
f6bcfd97
BP
9
10#---------------------------------------------------------------------------
8fa876ca 11class VtkFrame(wx.Frame):
f6bcfd97
BP
12 """
13 Simple example VTK window that contains a cone.
14 """
15 def __init__(self, parent, id, title):
8fa876ca
RD
16 wx.Frame.__init__(self, parent, id, title, size=(450, 300))
17 win = vtk.VTKRenderWindow(self, -1)
f6bcfd97
BP
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)
493f1553 29
f6bcfd97 30#---------------------------------------------------------------------------
8fa876ca
RD
31# Using new event binder
32wx_EVT_ADD_CONE = wx.NewEventType()
33EVT_ADD_CONE = wx.PyEventBinder(wx_EVT_ADD_CONE, 1)
493f1553 34
8fa876ca 35class AddCone(wx.PyEvent):
f6bcfd97 36 def __init__(self):
8fa876ca
RD
37 wx.PyEvent.__init__(self)
38 self.SetEventType(wx_EVT_ADD_CONE)
f6bcfd97 39
493f1553 40
8fa876ca 41class HiddenCatcher(wx.Frame):
f6bcfd97
BP
42 """
43 The "catcher" frame in the second thread.
44 It is invisible. It's only job is to receive
493f1553 45 Events from the main thread, and create
f6bcfd97 46 the appropriate windows.
493f1553 47 """
f6bcfd97 48 def __init__(self):
8fa876ca
RD
49 wx.Frame.__init__(self, None, -1, '')
50 self.Bind(EVT_ADD_CONE, self.AddCone)
f6bcfd97 51
493f1553 52 def AddCone(self,evt):
f6bcfd97 53 add_cone()
493f1553
RD
54
55
f6bcfd97 56#---------------------------------------------------------------------------
493f1553 57
8fa876ca 58class SecondThreadApp(wx.App):
f6bcfd97
BP
59 """
60 wxApp that lives in the second thread.
493f1553 61 """
f6bcfd97
BP
62 def OnInit(self):
63 catcher = HiddenCatcher()
64 #self.SetTopWindow(catcher)
8fa876ca 65 self.catcher = catcher
1e4a197e 66 return True
493f1553 67
f6bcfd97
BP
68#---------------------------------------------------------------------------
69
493f1553
RD
70def add_cone():
71 frame = VtkFrame(None, -1, "Cone")
1e4a197e 72 frame.Show(True)
493f1553 73