示例#1
0
    def wrapper(*args, **kw):
        script = get_mayavi_script_instance()
        if script is None and mayavi is not None:
            script = mayavi.script
        if script is None:
            def caller(script):
                """Callback that runs the function inside the mayavi
                app."""
                # Bind the 'mayavi' name to the script instance
                func.func_globals['mayavi'] = script
                # Run the function in the event loop.
                g = script.window.application.gui
                g.invoke_later(func, *args, **kw)

            # Start up mayavi and invoke caller when the script instance
            # is available.
            m = Mayavi()
            m.on_trait_change(caller, 'script')
            # Run the mayavi app.
            m.main()
        else:
            ns = func.func_globals
            if not contains_mayavi(ns):
                # Bind the 'mayavi' name to the script instance
                ns['mayavi'] = script
            # Now run the function.
            func(*args, **kw)
示例#2
0
文件: mayavi2.py 项目: sjl421/code-2
    def wrapper(*args, **kw):
        script = get_mayavi_script_instance()
        if script is None and mayavi is not None:
            script = mayavi.script
        if script is None:

            def caller(script):
                """Callback that runs the function inside the mayavi
                app."""
                # Bind the 'mayavi' name to the script instance
                func.func_globals['mayavi'] = script
                # Run the function in the event loop.
                g = script.window.application.gui
                g.invoke_later(func, *args, **kw)

            # Start up mayavi and invoke caller when the script instance
            # is available.
            m = Mayavi()
            m.on_trait_change(caller, 'script')
            # Run the mayavi app.
            m.main()
        else:
            ns = func.func_globals
            if not contains_mayavi(ns):
                # Bind the 'mayavi' name to the script instance
                ns['mayavi'] = script
            # Now run the function.
            func(*args, **kw)
示例#3
0
 def new_engine(self):
     """ Creates a new engine, envisage or not depending on the
         options.
     """
     check_backend()
     if options.backend == 'envisage':
         from enthought.mayavi.plugins.app import Mayavi
         m = Mayavi(start_gui_event_loop=False)
         m.main()
         process_ui_events()
         window = m.application.workbench.active_window
         engine = window.get_service(Engine)
     elif options.backend == 'test':
         engine = NullEngine(name='Null Mlab Engine')
         engine.start()
     else:
         if options.offscreen:
             engine = OffScreenEngine(name='Mlab offscreen Engine')
             engine.start()
         else:
             engine = Engine(name='Mlab Engine')
             engine.start()
     self.current_engine = engine
     return engine
示例#4
0
 def new_engine(self):
     """ Creates a new engine, envisage or not depending on the
         options.
     """
     check_backend()
     if options.backend == 'envisage':
         from enthought.mayavi.plugins.app import Mayavi
         m = Mayavi(start_gui_event_loop=False)
         m.main()
         process_ui_events()
         window = m.application.workbench.active_window
         engine = window.get_service(Engine)
     elif options.backend == 'test':
         engine = NullEngine(name='Null Mlab Engine')
         engine.start()
     else:
         if options.offscreen:
             engine = OffScreenEngine(name='Mlab offscreen Engine')
             engine.start()
         else:
             engine = Engine(name='Mlab Engine')
             engine.start()
     self.current_engine = engine
     return engine