[vtkusers] wxVTKRenderWindowInteractor inside wxNotebook crashes

Kalle Pahajoki kalpaha at st.jyu.fi
Tue Feb 22 12:26:08 EST 2005


First of all, I am using Mandrake Linux 10.1 with Nvidia TNT2 and 
NVidia's drivers, wxPython and VTK 4.4 and 
vtk.wx.wxVTKRenderWindowInteractor that comes with it.

I tried to include a wxVTKRenderWindowInteractor (RWI from now on) 
inside a wxNotebook,
so that the RWI was contained in a wxPanel that was a page in the 
notebook (it was a bit more complicated, but the problem reduced
to this when I tried to simplified the code). The code would just crash 
If I ran it. The error messages are generally of the form:

The program 'xxx.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 7 error_code 3 request_code 2 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)

A further detail is that when I tried to run the program using the 
--sync switch, it would then run without crashing.

I then found a simple example that worked, that had the RWI as the 
wxNotebook page itself. I tried to modify the example
to have the RWI inside a panel, and it then crashed similiarly. The 
attached example works, but to get it to crash one will
only need to  add a line

and change the line
        wxVTK = wxVTKRenderWindowInteractor(nb, -1)
to have p as RWI's parent:
        wxVTK = wxVTKRenderWindowInteractor(p, -1)
and then change the code from:
        nb.AddPage(wxVTK, "wxVTK")
to add p as the page:
        nb.AddPage(p, "wxVTK")

Is there a way to get the RWI contained in a wxPanel working as a 
wxNotebook page?

Kalle Pahajoki

<-- Example of RWI inside wxNotebook, works -->
import sys
from wxPython.wx import *
from vtk import *
from vtk.wx.wxVTKRenderWindowInteractor import *

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")
        wxVTK = wxVTKRenderWindowInteractor(nb, -1)
        ren = vtkRenderer ()
        wxVTK.GetRenderWindow ().AddRenderer (ren)

        nb.AddPage(wxVTK, "wxVTK")
        # Some other actors are added lately...
        Mapper = vtkPolyDataMapper()
        Plane = vtkPlaneSource()
       #Comment out the following line and it will work
        Actor = vtkActor()
class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame()
        return true

main = MyApp(0)

More information about the vtkusers mailing list