[vtkusers] VTK, Python, and Qt4

Doug Hackworth doug.hackworth at vanderbilt.edu
Tue Apr 29 11:51:20 EDT 2008


Greetings, VTK community.  I am attempting to write an application using 
the combination of VTK, Python, and Qt, and having some trouble.  I am 
relatively new to both VTK and Qt (though I think I have a reasonably 
solid grasp of each -- I can write things that function correctly), so I 
apologize if this request is too elementary.  But I have searched and 
searched for info on this until both my browser and I are blue in the 
face, to no avail, so I'm hoping that the assembled readership of this 
list can help me out.

I am using Ubuntu 7.04 server (amd64).  My VTK is version 5.0.4 with 
Python bindings and GUI support enabled, and it builds error-free.  VTK 
works with Python, no problem.  Qt works with Python, no problem. 
Mixing all three IS a problem.

Scenario 1:  If I attempt to use Qt4 Designer (v. 4.2.3) to create a GUI 
with the QVTKRenderWidget, I encounter exactly the same problem 
described in this post:

http://www.vtk.org/pipermail/vtkusers/2006-January/083348.html

(I'm surprised the issue is over two years old and still not fixed.) 
Does anyone know of a way to make QVTKRenderWidget work and/or work 
reliably with Qt Designer?  This would be my first choice, since my 
application will eventually have a large enough GUI that I'd like to 
avoid hand-coding the entire thing.  One the other hand, comments in the 
file QVTKRenderWidget.py itself recommend *not using the widget* due to 
excessive bugginess and using QVTKRenderWindowInteractor instead.  Does 
anyone have insights here?  Is the QVTKRenderWidget really that bad, 
even if one coaxes into working?

This segues into Scenario 2:

If instead I try to programmatically create a GUI with 
QVTKRenderWindowInteractor, I get two different errors, depending on the 
nature of my attempt.  If I code this:

	import vtk
	import qt
	(...)
	app = qt.QApplication(['QVTKRenderWindowInteractor'])
	qvtkWin = QVTKRenderWindowInteractor()

I get the error:

	NameError: name 'QVTKRenderWindowInteractor' is not defined

If instead I try this:

	qvtkWin = vtk.qt.QVTKRenderWindowInteractor()

(which seems logical, based on the placement of things in my 
VTK/Wrapping/Python directory) I get the following:

	AttributeError: 'module' object has no attribute 'qt'

Both errors suggest to me that I'm making some kind of embarrassing 
newbie mistake, but a) I'm pretty sure that my $PYTHONPATH is correct, 
and b) I haven't been able to find any other documentation (am I just 
missing it somehow?).

So, what's the recommendation of the experts?  :-)

If, with your help, I get all of this sorted out, I will gladly add a 
page to the VTK wiki describing the findings and the proper way to do 
things.

Many thanks,
Doug




More information about the vtkusers mailing list