How to use the envisage.api.Application function in envisage

To help you get started, we’ve selected a few envisage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / envisage / examples / MOTD / run.py View on Github external
def main():
    """ Run the application. """

    # Create an application containing the appropriate plugins.
    application = Application(
        id="acme.motd",
        plugins=[CorePlugin(), MOTDPlugin(), SoftwareQuotesPlugin()],
    )

    # Run it!
    return application.run()
github enthought / envisage / envisage / ui / tasks / tasks_application.py View on Github external
Int,
    List,
    Str,
    Vetoable,
)
from traits.etsconfig.api import ETSConfig


# Logging.
logger = logging.getLogger(__name__)

#: Default filename for saving layout information
DEFAULT_STATE_FILENAME = "application_memento"


class TasksApplication(Application):
    """The entry point for an Envisage Tasks application.

    This class handles the common case for Tasks applications and is
    intended to be subclassed to modify its start/stop behavior, etc.

    """

    # Extension point IDs.
    TASK_FACTORIES = "envisage.ui.tasks.tasks"
    TASK_EXTENSIONS = "envisage.ui.tasks.task_extensions"

    # Pickle protocol to use for persisting layout information. Subclasses may
    # want to increase this, depending on their compatibility needs. Protocol
    # version 2 is safe for Python >= 2.3. Protocol version 4 is safe for
    # Python >= 3.4.
    layout_save_protocol = Int(2)
github enthought / envisage / examples / MOTD_Using_Eggs / dist / run.py View on Github external
#
    # We do the imports here in case the Enthought eggs are loaded dyanmically
    # via the 'EGG_PATH'.
    from envisage.api import Application, EggPluginManager

    # Create a plugin manager that ignores all eggs except the ones that we
    # need for this example.
    plugin_manager = EggPluginManager(
        include = [
            'envisage.core', 'acme.motd', 'acme.motd.software_quotes'
        ]
    )

    # Create an application that uses the egg plugin manager to find its
    # plugins.
    application = Application(id='acme.motd', plugin_manager=plugin_manager)

    # Run it!
    return application.run()
github enthought / envisage / envisage / plugins / remote_editor / envisage_remote_editor.py View on Github external
RemoteEditorController

logger = logging.getLogger(__name__)


class EnvisageRemoteEditorController(RemoteEditorController):
    """ An implementation of a client controlling a remote editor, but also
        using envisage to retrieve an execution engine, and run the commands
        from the editor.
    """

    # Tell the Client code to play well with the wx or Qt4 event loop
    ui_dispatch = 'auto'

    # A reference to the Envisage application.
    application = Instance(Application)

    ###########################################################################
    # EnvisageRemoteEditorController interface
    ###########################################################################

    def run_file(self, path):
        """ Called by the server to execute a file.
        """
        shell = self.application.get_service(IPythonShell)
        shell.execute_file(path, hidden=False)

    def run_text(self, text):
        """ Called by the server to execute text.
        """
        shell = self.application.get_service(IPythonShell)
        shell.execute_command(text, hidden=False)
github enthought / envisage / envisage / ui / single_project / project.py View on Github external
##########################################################################
    # CLASS Attributes
    ##########################################################################

    #### public 'Project' class interface ####################################

    # Indicates whether instances of this project class are stored as files or
    # directories.  The rest of the single_project plugin will follow this
    # setting when using this project class.
    #
    # This is meant to be a constant for the lifetime of this class!
    PROJECTS_ARE_FILES = True

    # Current envisage application.
    application = Instance(Application, transient=True)

    #### protected 'Project' class interface #################################

    # Format used to create a unique name from a location and a counter.
    _unique_name_format = "%s_%s"

    ##########################################################################
    # Attributes
    ##########################################################################

    #### public 'Project' interface ##########################################

    # True if this project contains un-saved state (has been modified.)
    dirty = Bool(False, transient=True)

    # True if we allow save requests on the project.
github enthought / envisage / examples / Hello_World / hello_world.py View on Github external
"The %s application says %s" % (self.application.id, greeting)
            for greeting in ["Bonjour", "Hola"]
        ]

        return extensions


# Application entry point.
if __name__ == "__main__":

    # Create the application.
    #
    # An application is simply a collection of plugins. In this case we
    # specify the plugins explicitly, but the mechanism for finding plugins
    # is configurable by setting the application's 'plugin_manager' trait.
    application = Application(
        id="hello.world", plugins=[HelloWorld(), Greetings(), MoreGreetings()]
    )

    # Run it!
    application.run()
github enthought / envisage / envisage / ui / workbench / workbench_application.py View on Github external
# Enthought library imports.
from envisage.api import Application
from pyface.api import AboutDialog, Dialog, GUI, ImageResource
from pyface.api import SplashScreen
from pyface.workbench.api import IWorkbench
from traits.api import Callable, Instance, Str, Tuple

# Local imports.
from .workbench import Workbench


# Logging.
logger = logging.getLogger(__name__)


class WorkbenchApplication(Application):
    """ The entry point for an Envisage Workbench application.

    i.e. a GUI application whose user interface is provided by the workbench
    plugin.

    This class handles the common case for Workbench applications, and it is
    intended to be subclassed to change start/stop behaviour etc. In fact, I
    generally create a subclass for every Workbench application I write since
    it is a good place to put branding information etc.

    """

    #### 'WorkbenchApplication' interface #####################################

    # The Pyface GUI for the application (this is here to make it easy for
    # parts of the application to get a reference to the GUI so they can get
github enthought / envisage / envisage / twisted_application.py View on Github external
"""


# Standard library imports.
import logging

# Enthought library imports.
from envisage.api import Application


# Logging.
logger = logging.getLogger(__name__)


class TwistedApplication(Application):
    """ A non-GUI application with a twisted reactor event loop. """

    def start(self):
        """ Start the application. """

        started = super(TwistedApplication, self).start()

        # Don't start the event loop if the start was vetoed.
        if started:
            from twisted.internet import reactor

            logger.debug('---------- reactor starting ----------')
            reactor.run()

        return started