[vtkusers] Python Qt4 Vtk (5.8/5.10.1) Ubuntu 12.04

Niels Linnemann ne.linnemann at gmail.com
Sat Jan 5 13:39:34 EST 2013


Hi

I've been struggling with this for a while now and don't seem to get any
further.

I have a Win 7 machine running the latest pythonxy release and a CentOS 6.3
machine using python 2.6, PyQt-4.6 and vtk 5.6.

I'm embedding a VTK render window inside a QFrame.

This example works on the other two machines.

from PyQt4 import QtCore, QtGui

from PyQt4.QtGui import QApplication

import vtk

from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

import sys

 class Ui_MainWindow(object):

def setupUi(self, MainWindow):

MainWindow.setObjectName("MainWindow")

MainWindow.resize(603, 553)

self.centralWidget = QtGui.QWidget(MainWindow)

self.gridlayout = QtGui.QGridLayout(self.centralWidget)

self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)

self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)

MainWindow.setCentralWidget(self.centralWidget)

 class SimpleView(QtGui.QMainWindow):

 def __init__(self, parent = None):

QtGui.QMainWindow.__init__(self, parent)

self.ui = Ui_MainWindow()

self.ui.setupUi(self)

self.ren = vtk.vtkRenderer()

self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)

iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()

cube = vtk.vtkCubeSource()

cube.SetXLength(200)

cube.SetYLength(200)

cube.SetZLength(200)

cube.Update()

cm = vtk.vtkPolyDataMapper()

cm.SetInputConnection(cube.GetOutputPort())

ca = vtk.vtkActor()

ca.SetMapper(cm)

self.ren.AddActor(ca)

self.axesActor = vtk.vtkAnnotatedCubeActor();

self.axesActor.SetXPlusFaceText('R')

self.axesActor.SetXMinusFaceText('L')

self.axesActor.SetYMinusFaceText('H')

self.axesActor.SetYPlusFaceText('F')

self.axesActor.SetZMinusFaceText('P')

self.axesActor.SetZPlusFaceText('A')

self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)

self.axesActor.GetTextEdgesProperty().SetLineWidth(2)

self.axesActor.GetCubeProperty().SetColor(0,0,1)

self.axes = vtk.vtkOrientationMarkerWidget()

self.axes.SetOrientationMarker(self.axesActor)

self.axes.SetInteractor(iren)

self.axes.EnabledOn()

self.axes.InteractiveOn()

self.ren.ResetCamera()

iren.Initialize()


 if __name__ == "__main__":

 app = QApplication(sys.argv)

window = SimpleView()

window.show()
sys.exit(app.exec_())

On the Ubuntu machine no window pops up.
I have 2 machines with very different hardware and same result.

Commenting the "iren.Initialize()" line will make the window show, but no
render.

I have tried using the built-in ubuntu vtk python wrapping (5.8) package.
I have compiled both vtk 5.8 and 5.10.1 from source, but same result
(removed the default package before).

The challenge I'm facing is that I get absolutely no error messages or
debug info that I can work with.

I'm on the verge on giving up on Ubuntu on this issue.

Does anyone have anything I could try before I reformat to another distro?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130105/69fdd981/attachment.htm>


More information about the vtkusers mailing list