[vtkusers] VTK + Qt in a remote ssh session

Ignacio Fernández Galván jellby at yahoo.com
Tue Mar 6 05:20:08 EST 2018


Hi,

I'm trying to run an application using python, VTK and Qt in a remote 
box through an ssh connection. A simple example with just python+VTK 
works by using vglrun, but when I try python+VTK+Qt I get:

ERROR: In 
/work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, 
line 785
vtkXOpenGLRenderWindow (0x1e5bde0): GLEW could not be initialized.

If instead of a plain ssh connection I use the ThinLinc client, then 
with vglrun both work. How could I solve/debug this?

I'm using VTK 8.1.0 installed with pip, and I've tried differet PyQt4, 
PyQt5, PySide versions all to the same effect.

Thanks,
Ignacio


These are my sample files:

test.py
===============================================
import vtk
cylinder = vtk.vtkCylinderSource()
cylinder.SetResolution(8)
cylinderMapper = vtk.vtkPolyDataMapper()
cylinderMapper.SetInputConnection(cylinder.GetOutputPort())
cylinderActor = vtk.vtkActor()
cylinderActor.SetMapper(cylinderMapper)
cylinderActor.GetProperty().SetColor(1,0,0)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(cylinderActor) 
 

iren.Initialize()
iren.Start()
===============================================

testqt.py
===============================================
import sys 
 

import vtk
from qtpy import QtCore, QtGui, QtWidgets
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

class MainWindow(QtWidgets.QMainWindow):

     def __init__(self, parent = None):
         QtWidgets.QMainWindow.__init__(self, parent)

         self.frame = QtWidgets.QFrame()

         self.vl = QtWidgets.QVBoxLayout()
         self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
         self.vl.addWidget(self.vtkWidget)

         self.ren = vtk.vtkRenderer()
         self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
         self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

         # Create source
         source = vtk.vtkSphereSource()
         source.SetCenter(0, 0, 0)
         source.SetRadius(5.0)

         # Create a mapper
         mapper = vtk.vtkPolyDataMapper()
         mapper.SetInputConnection(source.GetOutputPort())

         # Create an actor
         actor = vtk.vtkActor()
         actor.SetMapper(mapper)

         self.ren.AddActor(actor)

         self.ren.ResetCamera()

         self.frame.setLayout(self.vl)
         self.setCentralWidget(self.frame)

         self.show()
         self.iren.Initialize()

if __name__ == "__main__":
     app = QtWidgets.QApplication(sys.argv)
     window = MainWindow()
     sys.exit(app.exec_())
===============================================


More information about the vtkusers mailing list