当前位置: 首页>>代码示例>>Python>>正文


Python Factory.scene方法代码示例

本文整理汇总了Python中twisted.internet.protocol.Factory.scene方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.scene方法的具体用法?Python Factory.scene怎么用?Python Factory.scene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.Factory的用法示例。


在下文中一共展示了Factory.scene方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: serve_tcp

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import scene [as 别名]
def serve_tcp(engine=None, port=8007, logto=sys.stdout, max_connect=1):
    """Serve the `M2TCP` protocol using the given `engine` on the
    specified `port` logging messages to given `logto` which is a
    file-like object.  This function will block till the service is
    closed.  There is no need to call `mlab.show()` after or before
    this.  The Mayavi UI will be fully responsive.

    **Parameters**

     :engine: Mayavi engine to use. If this is `None`,
              `mlab.get_engine()` is used to find an appropriate engine.

     :port: int: port to serve on.

     :logto: file: File like object to log messages to.  If this is
                   `None` it disables logging.

     :max_connect: int: Maximum number of simultaneous connections to
                        support.

    **Examples**

    Here is a very simple example::

        from mayavi import mlab
        from mayavi.tools import server
        mlab.test_plot3d()
        server.serve_tcp()

    The TCP server will listen on port 8007 by default in the above.
    Any data sent to the server is simply exec'd, meaning you can do
    pretty much anything you want.  The `engine`, `scene`, `camera` and
    `mlab` are all available and can be used.  For example after running
    the above you can do this::

        $ telnet localhost 8007
        Trying 127.0.0.1...
        Connected to localhost.
        Escape character is '^]'.
        scene.camera.azimuth(45)
        mlab.clf()
        mlab.test_contour3d()
        scene.camera.zoom(1.5)

    **Warning**

    Data sent is exec'd so this is a security hole.
    """

    from mayavi import mlab
    e = engine or mlab.get_engine()
    # Setup the factory with the right attributes.
    factory = Factory()
    factory.protocol = M2TCP
    factory.maxConnect = max_connect
    factory.numConnect = 0
    factory.engine = e
    factory.scene = e.current_scene.scene
    factory.mlab = mlab

    if logto is not None:
        log.startLogging(logto)
    log.msg('Serving Mayavi2 TCP server on port', port)
    log.msg('Using Engine', e)

    # Register the running wxApp.
    reactor.registerWxApp(wx.GetApp())
    # Listen on port 9007 using above protocol.
    reactor.listenTCP(port, factory)
    # Run the server + app.  This will block.
    reactor.run()
开发者ID:PerryZh,项目名称:mayavi,代码行数:73,代码来源:server.py


注:本文中的twisted.internet.protocol.Factory.scene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。