[vtkusers] vtkRenderWindow within wxPython (wxVTKRenderWindow by Robin Dunn)

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Wed Mar 21 15:11:29 EST 2001


hi,

>>>>> "Eric" == Eric Boix <frog at creatis.insa-lyon.fr> writes:

    Eric>         Dear VTK (and wxPython) users, I'm trying to adapt
    Eric> David Gobbi's $VTK/python/vtkRenderWidget.py to wxPython. I
    Eric> pulled Robin Dunn's "plugin" wxVTKRenderWindow (from
    Eric> http://download.sourceforge.net/wxpython/wxPython-demo-2.2.5.tar.gz
    Eric> i.e. the official demos of wxPython).

If you can wait - dont bother doing this yet.  I already spent quite
some time doing just this (adapting vtkRenderWidget.py to wxPython).
It works under linux and Sebastien Barre is testing it under windows.
I will let you know once it is finished.  I will also send this to
Robin Dunn for inclusion with wxPython.  If you want I can mail you
this.  I dont know if it works on windows...

    Eric> This works fine when calling it within a wxFrame e.g. :
    Eric> frame = wxFrame(None, -1, "vtkwxRenderWidget Test",
    Eric> size=(550,400)) vtkWxRender = wxVTKRenderWindow(frame) The
    Eric> vtkRenderWindow lies nicely inside the X11 window containing
    Eric> the wxFrame.

    Eric> But (there is a but) this fails when calling it within a
    Eric> wxPanel e.g.  frame = wxFrame(None, -1, "vtkwxRenderWidget
    Eric> Test", size=(550,400)) panel = wxPanel(frame, -1)
    Eric> vtkWxRender = wxVTKRenderWindow(panel) The vtkRenderWindow
    Eric> then lives within a new X11 window (different from the X11
    Eric> window containing the wxFrame) !

I am no wxPython expert but here is some info from the wx docs

  A panel is a window on which controls are placed. It is usually
  placed within a frame. It contains minimal extra functionality over
  and above its parent class wxWindow; its main purpose is to be
  similar in appearance and functionality to a dialog, but with the
  flexibility of having any window as a parent.

So maybe you are using the wrong widget.


    Eric> Of course :-) I need more than one vtkRenderWindow inside my
    Eric> wxFrame.  Who can be satisfied with a single renderer when
    Eric> one can have many ? :-)

Try code like this instead - it should work (this is taken straight
from one of my test programs):


        frame = wxFrame (NULL, -1, "wxVTKRenderWindow Demo!",
                         size=(600,400))
        nb = wxNotebook (frame, -1)

        # The wxVTKRenderWindow
        wxvtk = wxVTKRenderWindow (nb, -1)
        nb.AddPage (wxvtk, "wxVTKRenderWindow")
        self.SetupVTK (wxvtk)
	nb.Refresh ()
	# do your vtk stuff here
	# add other notebook widgets if you want.


Of course, you can create more notebook pages with other
wxVTKRenderWindows.  I even have a working MDIDemo test program that
creates mutliple MDI frames with vtkRenderWindows embedded.  If you
want I can mail you the code.  Let me know.  It may still have bugs
with Windows but works perfectly under linux.


Hope this helps.
prabhu




More information about the vtkusers mailing list