]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/viewer_basics.py
   1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) 
   3 # o Updated for wx namespace 
   4 # o No idea what this does. 
   8 import  wx
.lib
.vtk  
as vtk
 
  10 #--------------------------------------------------------------------------- 
  11 class VtkFrame(wx
.Frame
): 
  13         Simple example VTK window that contains a cone. 
  15     def __init__(self
, parent
, id, title
): 
  16         wx
.Frame
.__init
__(self
, parent
, id, title
, size
=(450, 300)) 
  17         win 
= vtk
.VTKRenderWindow(self
, -1) 
  19         renWin 
= win
.GetRenderWindow() 
  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
) 
  30 #--------------------------------------------------------------------------- 
  31 # Using new event binder 
  32 wx_EVT_ADD_CONE 
= wx
.NewEventType() 
  33 EVT_ADD_CONE 
= wx
.PyEventBinder(wx_EVT_ADD_CONE
, 1) 
  35 class AddCone(wx
.PyEvent
): 
  37         wx
.PyEvent
.__init
__(self
) 
  38         self
.SetEventType(wx_EVT_ADD_CONE
) 
  41 class HiddenCatcher(wx
.Frame
): 
  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. 
  49         wx
.Frame
.__init
__(self
, None, -1, '') 
  50         self
.Bind(EVT_ADD_CONE
, self
.AddCone
) 
  52     def AddCone(self
,evt
): 
  56 #--------------------------------------------------------------------------- 
  58 class SecondThreadApp(wx
.App
): 
  60         wxApp that lives in the second thread. 
  63         catcher 
= HiddenCatcher() 
  64         #self.SetTopWindow(catcher) 
  65         self
.catcher 
= catcher
 
  68 #--------------------------------------------------------------------------- 
  71    frame 
= VtkFrame(None, -1, "Cone")