Embed vtk window in a QTabWidget

K

Kene Meniru

Hi:

I know this may not be the right place to post this but I found some other
PyQt questions and I am desperate.

My app is the Window class object below and I am trying to embed a
QVTKRenderWindowInteractor class called ConeWindow in its QTabWidget. First
of all running ConeWindow gives out QPainter::begin:, QPainter::save:,
QPainter::setClipRegion:, and QPainter::restore: messages. This may be what
is crashing the Window class when I embed it.

Can somebody help me here? Thanks.

-------------------
#!/usr/bin/env python
from PyQt4 import QtGui, QtCore
import vtk
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
import sys


class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.treeArea = QtGui.QTreeWidget()
self.textArea = QtGui.QTextEdit()
self.viewArea = QtGui.QTabWidget()
self.msgArea = QtGui.QTextBrowser()
# Add tabs
self.modelTab = ConeWindow(self)
#self.modelTab = QtGui.QTextBrowser()
self.reportTab = QtGui.QTextBrowser()
self.viewArea.addTab(self.modelTab, "Model")
self.viewArea.addTab(self.reportTab, "Report")
# Window area splitters
self.vSplitter = QtGui.QSplitter(QtCore.Qt.Vertical)
self.vSplitter.addWidget(self.viewArea)
self.vSplitter.addWidget(self.msgArea)
self.hSplitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
self.hSplitter.addWidget(self.treeArea)
self.hSplitter.addWidget(self.textArea)
self.hSplitter.addWidget(self.vSplitter)
# Assign mainwindow
self.setCentralWidget(self.hSplitter)


class ConeWindow(QVTKRenderWindowInteractor):
def __init__(self, parent=None):
QVTKRenderWindowInteractor.__init__(self, parent)
self._parent = parent
self.vrenderer = vtk.vtkRenderer()
self.renderWindow = self.GetRenderWindow()
self.renderWindow.AddRenderer(self.vrenderer)
self.iren = self.renderWindow.GetInteractor()
#
self.cone = vtk.vtkConeSource()
self.cone.SetResolution(8)
self.coneMapper = vtk.vtkPolyDataMapper()
self.coneMapper.SetInput(self.cone.GetOutput())
self.coneActor = vtk.vtkActor()
self.coneActor.SetMapper(self.coneMapper)
self.vrenderer.AddActor(self.coneActor)
self.iren.Initialize()

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top