[vtkusers] vtkpython and vtkTk*Widget's

William Greathouse william.greathouse at the-greathouses.net
Sat Jan 25 18:35:53 EST 2003


All,

I am working with VTK (nightly) and the Python bindings.  
When use the vtkTkImageViewerWidget or vtkTkRenderWidget,
I receive an error dialog when attempting to quit the 
running script via a button.

  The instruction at "0xXXXXXXXX" referenced memory at 
  "0xXXXXXXXX". The memory could not be "read".
  Click on OK to terminate the program.

If I close the window (click wm close box) or Alt-F4, I do 
not get the error dialog. 

I am running Windows XP, VTKnightly, and Python 2.2.2.

I have rebuilt from source -- TCL 8.3.5, Tk 8.3.5, Python 2.2.2.
I have also tested with prebuilt sources (except for VTK nightly 
which is missing the vtkRenderingPythonTkWidgets.dll).  I receive 
the same result.  I have removed every instance I can locate of 
conflicting libraries and environments and rebuilt.

It appears to be related to the order of destruction of the 
widgets.  Is there a sequence I can use to avoid this issue?

Thanks in advance.

Bill

====
Here is my sample code for vtkTkRenderWidget -- lifted and 
adapted from the Python wrapping sample main.
====
  import Tkinter
  from Tkinter import *
  from vtkpython import *

  from vtkTkRenderWidget import vtkTkRenderWidget

  #------------------------------------------------------

  # create root window
  root = Tk()

  # create vtkTkRenderWidget
  pane = vtkTkRenderWidget(root,width=300,height=300)

  ren = vtkRenderer()
  pane.GetRenderWindow().AddRenderer(ren)

  cone = vtkConeSource()
  cone.SetResolution(8)

  coneMapper = vtkPolyDataMapper()
  coneMapper.SetInput(cone.GetOutput())

  coneActor = vtkActor()
  coneActor.SetMapper(coneMapper)

  ren.AddActor(coneActor)

  # pack the pane into the tk root
  pane.pack()

  button = Button(root,text="Quit",command=root.quit)
  button.pack(fill='x',expand='t')

  # start the tk mainloop
  root.mainloop()




More information about the vtkusers mailing list