[vtkusers] wxPython & VTK: Problem with cone6.py in WX

Kenneth Evans evans at aps.anl.gov
Tue May 13 15:39:29 EDT 2008


Hi,

Attached is an attempt to use the cone6.py tutorial with WX.  I have made
the minimum changes to cone6.py that I thought necessary to make it run
under WX.  As such, it could serve as a more detailed example than given in
wxVTKRenderWindow.py and wxVTKRenderWindowInteractor.py.  It would have
helped me to have had such an example (but perhaps working better ;-).

There are two switches at the top of the file:

USE_WX: True to use WX, False to do the original cone6.py.
USE_INTERACTOR_ONLY:  Only relevant if USE_WX = True. Explained below.

The problem is that virtually all VTK examples have a vtkRenderWindow.  The
ones that use vtkRenderWindowInteractor add that in addition.  I have been
unable to successfully mimic that behavior.  Perhaps someone can point out
why.  To show what happens, use USE_WX = True and USE_INTERACTOR_ONLY =
False.

It is possible to do what cone6.py does if you use a
wxVTKRenderWindowInteractor _in place of_ the wxVTKRenderWindow and also use
it in place of creating a separate wxVTKRenderWindowInteractor.  This is
what you get with USE_WX = True and USE_INTERACTOR_ONLY = True.  While this
seems to work, it entails more changes in modifying existing examples and is
a different pattern than in dozens of VTK examples, including cone6.py,
cone6.cxx, etc.

I also feel it _should_ work this way.  The problem seems to be that:

  iren = vtk.vtkRenderWindowInteractor()
  iren.SetRenderWindow(renWin)

goes to:

    iren = wxVTKRenderWindowInteractor(frame, wx.ID_ANY)
    iren.SetRenderWindow(renWin.GetRenderWindow())

would be the appropriate change.  However, this doesn't work well and gives
a small plot scrunched up in the upper left corner of the frame.

Have I done something wrong?

In addition, using the wxVTKRenderWindowInteractor-only design pattern,
while it works in this case, is crashing python.exe (with an invalid access
error) in other cases.  I won't present these here until I have banged on
them more myself, but I mention them because perhaps the problem is with
what I am doing here.

Thanks for any help.

	-Ken


 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Cone6WX.py
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080513/be1fbb83/attachment.txt>


More information about the vtkusers mailing list