[vtkusers] Unable to see canvas of VTKRender window on a GUI designed using PyQt4
Manjunath K E
ke.manjunath at gmail.com
Fri Aug 21 13:19:24 EDT 2015
Hi
I have installed vtk, at, pyqt, python vtk using below commands.
sudo apt-get install libvtk5.8-qt4 libvtk5-qt4-dev libvtk5-dev
libvtk5.8 python-qt4 python-vtk qt4-designer pyqt4-dev-tools
python-qt4-gl libqt4-opengl libqt4-assistant
I have a following program. The sample.py is generated from sample.ui
(which is desinged using qt4designer) using pyuic4 command.
=================sample.py===============
from PyQt4 import QtCore, QtGui
from vtk.qt4 import *
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from vtk import *
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(626, 320)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.toolButton = QtGui.QToolButton(self.centralwidget)
self.toolButton.setGeometry(QtCore.QRect(30, 10, 51, 25))
self.toolButton.setObjectName(_fromUtf8("toolButton"))
self.qvtkWidget = QVTKRenderWindowInteractor(self.centralwidget)
self.qvtkWidget.setGeometry(QtCore.QRect(9, 60, 161, 181))
self.qvtkWidget.setObjectName(_fromUtf8("qvtkWidget"))
self.radioButton = QtGui.QRadioButton(self.centralwidget)
self.radioButton.setGeometry(QtCore.QRect(280, 20, 116, 22))
self.radioButton.setObjectName(_fromUtf8("radioButton"))
self.toolButton_2 = QtGui.QToolButton(self.centralwidget)
self.toolButton_2.setGeometry(QtCore.QRect(290, 80, 23, 25))
self.toolButton_2.setObjectName(_fromUtf8("toolButton_2"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(290, 150, 98, 27))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.line = QtGui.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(300, 210, 281, 16))
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName(_fromUtf8("line"))
self.line_2 = QtGui.QFrame(self.centralwidget)
self.line_2.setGeometry(QtCore.QRect(393, 80, 20, 121))
self.line_2.setFrameShape(QtGui.QFrame.VLine)
self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
self.line_2.setObjectName(_fromUtf8("line_2"))
self.horizontalLayoutWidget = QtGui.QWidget(self.centralwidget)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(430, 50, 160,
80))
self.horizontalLayoutWidget.setObjectName(_fromUtf8("horizontalLayoutWidget"))
self.horizontalLayout =
QtGui.QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 626, 25))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile"))
self.menuEdit = QtGui.QMenu(self.menubar)
self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.actionOpen = QtGui.QAction(MainWindow)
self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
self.actionAbout_IncoisVis = QtGui.QAction(MainWindow)
self.actionAbout_IncoisVis.setObjectName(_fromUtf8("actionAbout_IncoisVis"))
self.actionSave = QtGui.QAction(MainWindow)
self.actionSave.setObjectName(_fromUtf8("actionSave"))
self.actionSave_As = QtGui.QAction(MainWindow)
self.actionSave_As.setObjectName(_fromUtf8("actionSave_As"))
self.actionAnimate = QtGui.QAction(MainWindow)
self.actionAnimate.setObjectName(_fromUtf8("actionAnimate"))
self.menuFile.addAction(self.actionOpen)
self.menuFile.addAction(self.actionSave)
self.menuFile.addAction(self.actionSave_As)
self.menuFile.addAction(self.actionAnimate)
self.menuHelp.addAction(self.actionAbout_IncoisVis)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuEdit.menuAction())
self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.toolButton.setText(QtGui.QApplication.translate("MainWindow",
"...", None, QtGui.QApplication.UnicodeUTF8))
self.radioButton.setText(QtGui.QApplication.translate("MainWindow",
"RadioButton", None, QtGui.QApplication.UnicodeUTF8))
self.toolButton_2.setText(QtGui.QApplication.translate("MainWindow", "...",
None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("MainWindow",
"PushButton", None, QtGui.QApplication.UnicodeUTF8))
self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow",
"File", None, QtGui.QApplication.UnicodeUTF8))
self.menuEdit.setTitle(QtGui.QApplication.translate("MainWindow",
"Edit", None, QtGui.QApplication.UnicodeUTF8))
self.menuHelp.setTitle(QtGui.QApplication.translate("MainWindow",
"Help", None, QtGui.QApplication.UnicodeUTF8))
self.actionOpen.setText(QtGui.QApplication.translate("MainWindow",
"Open", None, QtGui.QApplication.UnicodeUTF8))
self.actionAbout_IncoisVis.setText(QtGui.QApplication.translate("MainWindow",
"About IncoisVis", None, QtGui.QApplication.UnicodeUTF8))
self.actionSave.setText(QtGui.QApplication.translate("MainWindow",
"Save", None, QtGui.QApplication.UnicodeUTF8))
self.actionSave_As.setText(QtGui.QApplication.translate("MainWindow", "Save
As", None, QtGui.QApplication.UnicodeUTF8))
self.actionAnimate.setText(QtGui.QApplication.translate("MainWindow",
"Animate", None, QtGui.QApplication.UnicodeUTF8))
==================================================
================prog.py======================
import sys
from PyQt4 import *
import os
import platform
import stat
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sample
class MainWindow(QMainWindow, sample.Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
form = MainWindow()
form.show()
sys.exit(app.exec_())
==============================================
To Run :
*python ./prog.py *
I get the output gui, but in that GUI the canvas related to VTK render
Window is not appearing. Could you please any1 help me.
Thanks and Regards,
Manjunath K E
Help Ever Hurt Never
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150821/4f523634/attachment.html>
More information about the vtkusers
mailing list