Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > contrib-backports > by-pkgid > 5a28ce08f20e322d24ac159a4334c346 > files > 2652

python-enthought-mayavi2-2.2.0-1mdv2008.1.x86_64.rpm

"""A runnable that binds the loaded scene plugins into the python shell.

"""
# Author: Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
# Copyright (c) 2006, Enthought, Inc.
# License: BSD Style.

# Enthought library imports.
from enthought.envisage.api import ApplicationObject

from enthought.traits.api import Any
from enthought.tvtk.plugins.scene.services import ITVTKSCENE

##########################################################################
# `TestApplicationObject` class
##########################################################################
class TestApplicationObject(ApplicationObject):
    """ A runnable that binds the ITVTKSCENE service to the python
    shell."""

    # FIXME: the base class does not define this (yet).  If this is
    # defined then the core plugin injects the application before
    # running the code in init.
    application = Any
    
    ###########################################################################
    # 'ApplicationObject' interface.
    ###########################################################################

    def init(self):
        """ Runs the application object!

        This simply binds the tvtk scene plugin on the python shell.

        """

        app = self.application
        tsp = app.get_service(ITVTKSCENE)
        ps = app.get_service('enthought.plugins.IPythonShell')
        ps.bind('scene_plugin', tsp)