vtkmodules.gtk.GtkVTKRenderWindow#

Description:

Provides a simple VTK widget for pyGtk. This embeds a vtkRenderWindow inside a GTK widget. This is based on vtkTkRenderWidget.py. The GtkVTKRenderWindowBase class provides the abstraction necessary for someone to use their own interaction behaviour. The method names are similar to those in vtkInteractorStyle.h.

The class uses the gtkgl.GtkGLArea widget (gtkglarea). This avoids a lot of problems with flicker.

There is a working example at the bottom.

Credits:

Thanks to Dave Reed for testing the code under various platforms and for his suggestion to use the GtkGLArea widget to avoid flicker related issues.

Created by Prabhu Ramachandran, March 2001.

Using GtkGLArea, March, 2002.

Bugs:

(*) There is a focus related problem. Tkinter has a focus object that handles focus events. I don’t know of an equivalent object under GTK. So, when an ‘enter_notify_event’ is received on the GtkVTKRenderWindow I grab the focus but I don’t know what to do when I get a ‘leave_notify_event’.

(*) Will not work under Win32 because it uses the XID of a window in OnRealize. Suggestions to fix this will be appreciated.

Module Contents#

Classes#

GtkVTKRenderWindowBase

A base class that enables one to embed a vtkRenderWindow into a pyGTK widget. This class embeds the RenderWindow correctly. Provided are some empty methods that can be overloaded to provide a user defined interaction behaviour. The event handling functions have names that are somewhat similar to the ones in the vtkInteractorStyle class included with VTK.

GtkVTKRenderWindow

An example of a fully functional GtkVTKRenderWindow that is based on the vtkRenderWidget.py provided with the VTK sources.

Functions#

API#

class vtkmodules.gtk.GtkVTKRenderWindow.GtkVTKRenderWindowBase(*args)#

Bases: gtkgl.GtkGLArea

A base class that enables one to embed a vtkRenderWindow into a pyGTK widget. This class embeds the RenderWindow correctly. Provided are some empty methods that can be overloaded to provide a user defined interaction behaviour. The event handling functions have names that are somewhat similar to the ones in the vtkInteractorStyle class included with VTK.

Initialization

ConnectSignals()#
GetRenderWindow()#
GetRenderer()#
SetDesiredUpdateRate(rate)#

Mirrors the method with the same name in vtkRenderWindowInteractor.

GetDesiredUpdateRate()#

Mirrors the method with the same name in vtkRenderWindowInteractor.

SetStillUpdateRate(rate)#

Mirrors the method with the same name in vtkRenderWindowInteractor.

GetStillUpdateRate()#

Mirrors the method with the same name in vtkRenderWindowInteractor.

Render()#
OnRealize(*args)#
OnConfigure(wid, event=None)#
OnExpose(*args)#
OnDestroy(event=None)#
OnButtonDown(wid, event)#

Mouse button pressed.

OnButtonUp(wid, event)#

Mouse button released.

OnMouseMove(wid, event)#

Mouse has moved.

OnEnter(wid, event)#

Entering the vtkRenderWindow.

OnLeave(wid, event)#

Leaving the vtkRenderWindow.

OnKeyPress(wid, event)#

Key pressed.

OnKeyRelease(wid, event)#

Key released.

class vtkmodules.gtk.GtkVTKRenderWindow.GtkVTKRenderWindow(*args)#

Bases: vtkmodules.gtk.GtkVTKRenderWindow.GtkVTKRenderWindowBase

An example of a fully functional GtkVTKRenderWindow that is based on the vtkRenderWidget.py provided with the VTK sources.

Initialization

OnButtonDown(wid, event)#
OnButtonUp(wid, event)#
OnMouseMove(wid, event=None)#
OnEnter(wid, event=None)#
OnLeave(wid, event)#
OnKeyPress(wid, event=None)#
GetZoomFactor()#
SetZoomFactor(zf)#
GetPicker()#
Render()#
UpdateRenderer(x, y)#

UpdateRenderer will identify the renderer under the mouse and set up _CurrentRenderer, _CurrentCamera, and _CurrentLight.

GetCurrentRenderer()#
StartMotion(wid, event=None)#
EndMotion(wid, event=None)#
Rotate(x, y)#
Pan(x, y)#
Zoom(x, y)#
Reset()#
Wireframe()#
Surface()#
PickActor(x, y)#
vtkmodules.gtk.GtkVTKRenderWindow.main()#