[vtkusers] [VTK4.x + Python + wxPython + Win32] wxVTKRenderWindow

Eric Boix frog at creatis.insa-lyon.fr
Thu Mar 7 04:47:30 EST 2002


	Dear VTK + Python + wxPython users,

  Thanks to David Gobbi (and Prabhu Ramachandran) advice, I switched to
the version of wxVTKRenderWindow that comes with VTK4.x. This version
seems to be robust and portable enough for my usage. :-)

  Still I'd like to report an oddity (not a bug) on Windows2000 with this
version. The following bizare script freezes the display when selecting
the wxVTK tab of the noteBook. This script is bizare in the sense that
the vtkPipeline is not complete : it misses a vtkSource.
  They are two work around to this freezing behavior :
1/ if you add a source (comment out the line that goes
      Mapper.SetInput(Plane.GetOutput())
   in the script) then everything goes smoothly...
2/ if you first create the incomplete pipeline, and then add the page
   to the noteBook (move the two lines
       nb.AddPage(wxVTK, "wxVTK")
       nb.Refresh()
   at the end of the MainFrame.__init__ member function) then everything
   goes smoothly...

  On wxGTK, the behavior is the expected one. One gets the following
error message, but the display doesn't freeze :
ERROR: In [...]/BUILD/VTK/Rendering/vtkPolyDataMapper.cxx, line 74
vtkOpenGLPolyDataMapper (0x870b728): Mapper has no input.

  Anyhow, and IMVHO, this David Gobbi's version is far more achieved than
the one you can find in wxPython.

	Thanks in advance for any comment/advice,
	Yours,
	Eric Boix.	


--------------------------------------------------------
from wxPython.wx import *
from vtkpython import *
# This must be the VTK4.x cvs revision number 1.5. See
# http://public.kitware.com/cgi-bin/cvsweb.cgi/VTK/Wrapping/Python/wxVTKRenderWindow.py?cvsroot=VTK
from wxVTKRenderWindow import wxVTKRenderWindow

class MainFrame(wxFrame):

    def __init__(self, parent=None):
        wxFrame.__init__(self, parent, -1, "test", size = (400, 400))
        nb = wxNotebook(self, -1)
        # First page is empty just to postpone wxVTKRenderWindow
        nb.AddPage(wxWindow(nb, -1), "splash")
        # Second page 
        wxVTK = wxVTKRenderWindow(nb, -1)
        ren = vtkRenderer ()
        wxVTK.GetRenderWindow ().AddRenderer (ren)
        nb.AddPage(wxVTK, "wxVTK")
        nb.Refresh()
        # Some other actors are added lately...
        Mapper = vtkPolyDataMapper()
        Plane = vtkPlaneSource()
        # Comment out the following line and it will work
        #Mapper.SetInput(Plane.GetOutput())
        Actor = vtkActor()
        Actor.SetMapper(Mapper)
        ren.AddActor(Actor)

class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame()
        frame.Show(true)
        self.SetTopWindow(frame)
        wxYield()
        return true

main = MyApp(0)
main.MainLoop()




More information about the vtkusers mailing list