1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
""" The interactive Python shell plugin. """
# Enthought library imports.
from enthought.envisage.api import ExtensionPoint, Plugin
from enthought.traits.api import Dict, List, Str
class PythonShellPlugin(Plugin):
""" The interactive Python shell plugin. """
# Extension point Ids.
BINDINGS = 'enthought.plugins.python_shell.bindings'
COMMANDS = 'enthought.plugins.python_shell.commands'
VIEWS = 'enthought.envisage.ui.workbench.views'
#### 'IPlugin' interface ##################################################
# The plugin's unique identifier.
id = 'enthought.plugins.python_shell'
# The plugin's name (suitable for displaying to the user).
name = 'Python Shell'
#### Extension points offered by this plugin ##############################
bindings = ExtensionPoint(
List(Dict), id=BINDINGS, desc="""
This extension point allows you to contribute name/value pairs that
will be bound when the interactive Python shell is started.
e.g. Each item in the list is a dictionary of name/value pairs::
{'x' : 10, 'y' : ['a', 'b', 'c']}
"""
)
commands = ExtensionPoint(
List(Str), id=COMMANDS, desc="""
This extension point allows you to contribute commands that are
executed when the interactive Python shell is started.
e.g. Each item in the list is a string of arbitrary Python code::
'import os, sys'
'from enthought.traits.api import *'
Yes, I know this is insecure but it follows the usual Python rule of
'we are all consenting adults'.
"""
)
#### Contributions to extension points made by this plugin ################
# Bindings.
contributed_bindings = List(contributes_to=BINDINGS)
def _contributed_bindings_default(self):
""" Trait initializer. """
return [{'application' : self.application}]
# Views.
contributed_views = List(contributes_to=VIEWS)
def _contributed_views_default(self):
""" Trait initializer. """
# Local imports.
from view.python_shell_view import PythonShellView
from view.namespace_view import NamespaceView
return [PythonShellView, NamespaceView]
#### EOF ######################################################################
|