| 1 |
# (C) Copyright 2007-2025 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
""" The application interface. """ |
| 11 |
|
| 12 |
|
| 13 |
# Enthought library imports. |
| 14 |
from apptools.preferences.api import IPreferences |
| 15 |
from traits.api import Event, Instance, Str, VetoableEvent |
| 16 |
|
| 17 |
from .application_event import ApplicationEvent |
| 18 |
|
| 19 |
# Local imports. |
| 20 |
from .i_extension_registry import IExtensionRegistry |
| 21 |
from .i_import_manager import IImportManager |
| 22 |
from .i_plugin_manager import IPluginManager |
| 23 |
from .i_service_registry import IServiceRegistry |
| 24 |
|
| 25 |
|
| 26 |
class IApplication( |
| 27 |
IExtensionRegistry, IImportManager, IPluginManager, IServiceRegistry |
| 28 |
): |
| 29 |
"""The application interface.""" |
| 30 |
|
| 31 |
#: The application's globally unique identifier. |
| 32 |
id = Str |
| 33 |
|
| 34 |
#: The name of a directory (created for you) to which the application can |
| 35 |
#: read and write non-user accessible data, i.e. configuration information, |
| 36 |
#: preferences, etc. |
| 37 |
home = Str |
| 38 |
|
| 39 |
#: The name of a directory (created for you upon access) to which the |
| 40 |
#: application can read and write user-accessible data, e.g. projects |
| 41 |
#: created by the user. |
| 42 |
user_data = Str |
| 43 |
|
| 44 |
#: The root preferences node. |
| 45 |
preferences = Instance(IPreferences) |
| 46 |
|
| 47 |
#### Events #### |
| 48 |
|
| 49 |
#: Fired when the application is starting. This is the first thing that |
| 50 |
#: happens when the 'start' method is called. |
| 51 |
starting = VetoableEvent(ApplicationEvent) |
| 52 |
|
| 53 |
#: Fired when all plugins have been started. |
| 54 |
started = Event(ApplicationEvent) |
| 55 |
|
| 56 |
#: Fired when the plugin manager is stopping. This is the first thing that |
| 57 |
#: happens when the 'stop' method is called. |
| 58 |
stopping = VetoableEvent(ApplicationEvent) |
| 59 |
|
| 60 |
#: Fired when all plugins have been stopped. |
| 61 |
stopped = Event(ApplicationEvent) |
| 62 |
|
| 63 |
def run(self): |
| 64 |
"""Run the application. |
| 65 |
|
| 66 |
The same as:: |
| 67 |
|
| 68 |
if application.start(): |
| 69 |
application.stop() |
| 70 |
|
| 71 |
""" |