我正在尝试在Qt4窗口中嵌入VTK5可视化,但是没有太多运气。以下代码在我的Mac(10.6,Python 2.7)上不起作用:
from PyQt4 import QtGui
from vtk.qt4 import QVTKRenderWindowInteractor
import sys
class Window(QVTKRenderWindowInteractor.QVTKRenderWindowInteractor):
def __init__(self):
QVTKRenderWindowInteractor.QVTKRenderWindowInteractor.__init__(self,None)
if __name__=='__main__':
app = QtGui.QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
尝试运行代码时出现错误:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 2 (X_ChangeWindowAttributes)
Resource id in failed request: 0x1a310140
Serial number of failed request: 7
Current serial number in output stream: 9
有没有人知道可能会发生什么?请注意,如果我切换到
class ConeWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self,None)
我按预期弹出一个小空窗口。
答案 0 :(得分:2)
我最终想通了,所以我在这里提出解决方案,以防它对其他人有用。我安装了VTK5:
sudo port install vtk5 +python27
但我需要包含qt4_mac
变体。以下工作:
sudo port install vtk5 +python27 +qt4_mac