astrofrog
astrofrog

Reputation: 34091

Issue getting VTK to work with Qt

I'm trying to embed a VTK5 visualization inside a Qt4 window, but am not having much luck. The following code doesn't work on my Mac (10.6, Python 2.7):

from PyQt4 import QtGui
from vtk.qt4 import QVTKRenderWindowInteractor
import sys

class Window(QVTKRenderWindowInteractor.QVTKRenderWindowInteractor):
    def __init__(self):
        QVTKRenderWindowInteractor.QVTKRenderWindowInteractor.__init__(self,None)

if __name__=='__main__':
    app = QtGui.QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())

The error when I try to run the code is:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0x1a310140
  Serial number of failed request:  7
  Current serial number in output stream:  9

Does anyone have any idea what might be going on? Note that if I switch to

class ConeWindow(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self,None)

I get a small empty window popping up as expected.

Upvotes: 2

Views: 1229

Answers (1)

astrofrog
astrofrog

Reputation: 34091

I figured it out eventually so am putting the solution here in case it's useful to other people. I had installed VTK5 with:

sudo port install vtk5 +python27

but I needed to include the qt4_mac variant. The following worked:

sudo port install vtk5 +python27 +qt4_mac

Upvotes: 2

Related Questions