<div dir="ltr">Hi<div><br></div><div style>I've been struggling with this for a while now and don't seem to get any further.</div><div style><br></div><div style>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.</div>
<div style><br></div><div style>I'm embedding a VTK render window inside a QFrame.</div><div style><br></div><div style>This example works on the other two machines.</div><div style><br></div>
<p style="margin:0px">from PyQt4 import QtCore, QtGui<br></p>
<p style="margin:0px">from PyQt4.QtGui import QApplication</p>
<p style="margin:0px">import vtk</p>
<p style="margin:0px">from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor</p>
<p style="margin:0px">import sys</p>
<p style="margin:0px"> </p>
<p style="margin:0px">class Ui_MainWindow(object):</p>
<p style="margin:0px"> def setupUi(self, MainWindow):</p>
<p style="margin:0px"> MainWindow.setObjectName("MainWindow")</p>
<p style="margin:0px"> MainWindow.resize(603, 553)</p>
<p style="margin:0px"> self.centralWidget = QtGui.QWidget(MainWindow)</p>
<p style="margin:0px"> self.gridlayout = QtGui.QGridLayout(self.centralWidget)</p>
<p style="margin:0px"> self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)</p>
<p style="margin:0px"> self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)</p>
<p style="margin:0px"> MainWindow.setCentralWidget(self.centralWidget)</p>
<p style="margin:0px"> </p>
<p style="margin:0px">class SimpleView(QtGui.QMainWindow):</p>
<p style="margin:0px"> </p>
<p style="margin:0px"> def __init__(self, parent = None):</p>
<p style="margin:0px"> QtGui.QMainWindow.__init__(self, parent)</p>
<p style="margin:0px"> self.ui = Ui_MainWindow()</p>
<p style="margin:0px"> self.ui.setupUi(self)</p>
<p style="margin:0px"> self.ren = vtk.vtkRenderer()</p>
<p style="margin:0px"> self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)</p>
<p style="margin:0px"> iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()</p>
<p style="margin:0px"> cube = vtk.vtkCubeSource()</p>
<p style="margin:0px"> cube.SetXLength(200)</p>
<p style="margin:0px"> cube.SetYLength(200)</p>
<p style="margin:0px"> cube.SetZLength(200)</p>
<p style="margin:0px"> cube.Update()</p>
<p style="margin:0px"> cm = vtk.vtkPolyDataMapper()</p>
<p style="margin:0px"> cm.SetInputConnection(cube.GetOutputPort())</p>
<p style="margin:0px"> ca = vtk.vtkActor()</p>
<p style="margin:0px"> ca.SetMapper(cm)</p>
<p style="margin:0px"> self.ren.AddActor(ca)</p>
<p style="margin:0px"> self.axesActor = vtk.vtkAnnotatedCubeActor();</p>
<p style="margin:0px"> self.axesActor.SetXPlusFaceText('R')</p>
<p style="margin:0px"> self.axesActor.SetXMinusFaceText('L')</p>
<p style="margin:0px"> self.axesActor.SetYMinusFaceText('H')</p>
<p style="margin:0px"> self.axesActor.SetYPlusFaceText('F')</p>
<p style="margin:0px"> self.axesActor.SetZMinusFaceText('P')</p>
<p style="margin:0px"> self.axesActor.SetZPlusFaceText('A')</p>
<p style="margin:0px"> self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)</p>
<p style="margin:0px"> self.axesActor.GetTextEdgesProperty().SetLineWidth(2)</p>
<p style="margin:0px"> self.axesActor.GetCubeProperty().SetColor(0,0,1)</p>
<p style="margin:0px"> self.axes = vtk.vtkOrientationMarkerWidget()</p>
<p style="margin:0px"> self.axes.SetOrientationMarker(self.axesActor)</p>
<p style="margin:0px"> self.axes.SetInteractor(iren)</p>
<p style="margin:0px"> self.axes.EnabledOn()</p>
<p style="margin:0px"> self.axes.InteractiveOn()</p>
<p style="margin:0px"> self.ren.ResetCamera()</p>
<p style="margin:0px"> iren.Initialize()</p><p style="margin:0px"><br></p>
<p style="margin:0px"> </p>
<p style="margin:0px">if __name__ == "__main__":</p>
<p style="margin:0px"> </p>
<p style="margin:0px"> app = QApplication(sys.argv)</p>
<p style="margin:0px"> window = SimpleView()</p>
<p style="margin:0px"> window.show()</p>
<div style>sys.exit(app.exec_()) </div><div style><br></div><div style>On the Ubuntu machine no window pops up.</div><div style>I have 2 machines with very different hardware and same result.</div><div style><br></div><div style>
Commenting the "iren.Initialize()" line will make the window show, but no render.</div><div style><br></div><div style>I have tried using the built-in ubuntu vtk python wrapping (5.8) package.</div><div style>I have compiled both vtk 5.8 and 5.10.1 from source, but same result (removed the default package before).</div>
<div style><br></div><div style>The challenge I'm facing is that I get absolutely no error messages or debug info that I can work with.</div><div style><br></div><div style>I'm on the verge on giving up on Ubuntu on this issue.</div>
<div style><br></div><div style>Does anyone have anything I could try before I reformat to another distro?</div><div style><br></div><div style><br></div></div>