[vtkusers] wxPython & VTK: How to Destroy wxVTKRenderWindow without errors?

Kenneth Evans, Jr. evans at aps.anl.gov
Mon May 12 00:53:59 EDT 2008


Charl,

>> I've been using this for quite a long time.  Could you re-check that
>> you can't invoke that method on the wxVTKRWI?

There is no such method in my version.  It generates an exception if you try
to use it.  If you look at the code, there is, in fact, no such method.  I
have attached the code.

I was not able to use the wxVTKRenderWindow* versions in the current
distribution (5.0.4).  They gave an error owing to using wxPython, as I
recall.  I probably have it written down at work.  That is one of several
problems I had making VTK work with Python 2.5 and the current WX.  The
versions I am using are newer and have your name in them.  Apart from the
problems in this email thread, they seem to work well.

I got these versions from CVS under HEAD following a clue I got by Googling
vtkusers.  (They get eventually get installed into
INSTALL_DIR\lib\site-packages\vtk\wx.)  

In any event with these versions you can't replace the vtkRenderWindow* by
wxVTKRenderWindow* in cone6.py, owing to the reasons I have stated.  I have
found I _can_ make the cone6 tutorial interactor work by using
wxVTKRenderWindowInteractor _in place of_ wxVTKRenderWindow instead of in
addition to it as it was originally.

>> The wxVTKRWI creates its own RenderWindow.

... which is internal.  You can't do what is done in cone6.py and use the
same one as in renWin.

If you look at the attached code, what I said should make more sense.  We
are clearly using different versions.  Looks that that should be resolved
first, then it will probably all make sense.

Thanks,

        -Ken

-----Original Message-----
From: cpbotha at medvis.org [mailto:cpbotha at medvis.org] On Behalf Of Charl
Botha
Sent: Sunday, May 11, 2008 5:13 PM
To: Kenneth Evans, Jr.
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] wxPython & VTK: How to Destroy wxVTKRenderWindow
without errors?

On Sun, May 11, 2008 at 7:12 PM, Kenneth Evans, Jr. <evans at aps.anl.gov>
wrote:
> I have looked at this some more and also tried to get the cone6.py
tutorial
> to work.
>
> 1. The problem is that wxVTKRenderWindowInteractor doesn't seem to have a
> way to set the vtkRenderWindow.  In the cone6.py code block:
>
> There is no SetRenderWindow() if you use wxVTKRenderWindowInteractor.

Hmm, did you double-check?  I see the following:
>> print rwi
<vtk.wx.wxVTKRenderWindowInteractor.wxVTKRenderWindowInteractor; proxy
of <Swig Object of type 'wxWindow *' at 0xcb00948> >
>> print rwi.SetRenderWindow
<built-in method SetRenderWindow of vtkobject object at 0x0D07F350>

There is some swig-magic going on, so you don't see it in dir() calls
and in introspection-based autocompletion, but it's there.  You just
need to call it. :)

That being said: under normal circumstances, you should never need to
call this, except at shutdown, and even then it's probably not really
necessary.  The wxVTKRWI creates its own RenderWindow.

> 2. Using the cone6 tutorial with this line commented out and printing what
> is returned by the shutDownVTK() method I listed in the last message
(which
> is pretty much what you suggested), I find:
>
> self.ren.GetRenderWindow() and self.renWin.GetRenderWindow() are the same
> object (as I expected).  self.renWin.GetRenderWindow() is a different
> object.

This statement is self-contradictory.  What exactly do you mean here?

> 3.  This lack of a way to change the RenderWindow is also why you can't
use:
>
> wxRWI.SetRenderWindow(None)
>
> as you suggested.

I've been using this for quite a long time.  Could you re-check that
you can't invoke that method on the wxVTKRWI?

> 4. Perhaps the best question to ask is how do you get the cone6 tutorial
to
> work with WX, given that is missing SetRenderWindow?

As explained right up above, the wxVTKRWI creates its own
vtkRenderWindow.  Only thing you have to do is to create a vtkRenderer
and then install it as follows:
ren = vtk.vtkRenderer()
rwi.GetRenderWindow().AddRenderer(ren)

Good luck!
Charl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wxVTKRenderWindow.py
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080511/1b0dd02b/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wxVTKRenderWindowInteractor.py
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080511/1b0dd02b/attachment.txt>


More information about the vtkusers mailing list