Exemple #1
0
class PythonShellPane(TaskPane):
    """ A Tasks Pane containing a Pyface PythonShell
    """

    id = "pyface.tasks.contrib.python_shell.pane"
    name = "Python Shell"

    editor = Instance(PythonShell)

    bindings = List(Dict)
    commands = List(Str)

    def create(self, parent):
        """ Create the python shell task pane

        This wraps the standard pyface PythonShell
        """
        logger.debug("PythonShellPane: creating python shell pane")
        self.editor = PythonShell(parent)
        self.control = self.editor.control

        # bind namespace
        logger.debug("PythonShellPane: binding variables")
        for binding in self.bindings:
            for name, value in binding.items():
                self.editor.bind(name, value)

        # execute commands
        logger.debug("PythonShellPane: executing startup commands")
        for command in self.commands:
            self.editor.execute_command(command)

        logger.debug("PythonShellPane: created")

    def destroy(self):
        """ Destroy the python shell task pane
        """
        logger.debug("PythonShellPane: destroying python shell pane")
        self.editor.destroy()
        self.control = self.editor = None
        logger.debug("PythonShellPane: destroyed")
Exemple #2
0
class PythonShellPane(TaskPane):
    """ A Tasks Pane containing a Pyface PythonShell
    """
    id = 'pyface.tasks.contrib.python_shell.pane'
    name = 'Python Shell'
    
    editor = Instance(PythonShell)
    
    bindings = List(Dict)
    commands = List(Str)
    
    def create(self, parent):
        """ Create the python shell task pane
        
        This wraps the standard pyface PythonShell
        """
        logger.debug('PythonShellPane: creating python shell pane')
        self.editor = PythonShell(parent)
        self.control = self.editor.control
        
        # bind namespace
        logger.debug('PythonShellPane: binding variables')
        for binding in self.bindings:
            for name, value in binding.items():
                self.editor.bind(name, value)
        
        # execute commands
        logger.debug('PythonShellPane: executing startup commands')
        for command in self.commands:
            self.editor.execute_command(command)
               
        logger.debug('PythonShellPane: created')
    
    def destroy(self):
        """ Destroy the python shell task pane
        """
        logger.debug('PythonShellPane: destroying python shell pane')
        self.editor.destroy()
        self.control = self.editor = None
        logger.debug('PythonShellPane: destroyed')