python vtk-qt-demo.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python vtk-qt-demo.py相关的知识,希望对你有一定的参考价值。

"""
A simple example that uses the QVTKRenderWindowInteractor
class.
"""

try:
    from PySide import QtCore, QtGui
except ImportError:
    try:
        from PyQt4 import QtCore, QtGui
    except ImportError as err:
        raise ImportError("Cannot load either PyQt or PySide")

if __name__ == '__main__':
    # every QT app needs an app
    app = QtGui.QApplication(['QVTKRenderWindowInteractor'])

    # create the widget
    widget = QVTKRenderWindowInteractor()
    widget.Initialize()
    widget.Start()

    # if you dont want the 'q' key to exit comment this.
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtk.vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtk.vtkConeSource()
    cone.SetResolution(8)

    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInputConnection(cone.GetOutputPort())

    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    widget.SetPicker(vtk.vtkPointPicker())

    # show the widget
    widget.show()

    # start event processing
    sys.exit(app.exec_())

以上是关于python vtk-qt-demo.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python