コード例 #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.__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.__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 プロジェクト: kitchoi/mayavi
    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.__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.__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
ファイル: engine_manager.py プロジェクト: B-Rich/mayavi
    def new_engine(self):
        """ Creates a new engine, envisage or not depending on the
            options.
        """
        check_backend()
        if options.backend == "envisage":
            from 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
ファイル: engine_manager.py プロジェクト: rajnishs91/mayavi
 def new_engine(self):
     """ Creates a new engine, envisage or not depending on the
         options.
     """
     check_backend()
     if options.backend == 'envisage':
         from 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