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
|
""" The Envisage workbench. """
# Enthought library imports.
import enthought.pyface.workbench.api as pyface
from enthought.envisage.api import IApplication
from enthought.pyface.api import YES
from enthought.traits.api import Delegate, Instance
# Local imports.
from workbench_preferences import WorkbenchPreferences
from workbench_window import WorkbenchWindow
class Workbench(pyface.Workbench):
""" The Envisage workbench.
There is (usually) exactly *one* workbench per application. The workbench
can create any number of workbench windows.
"""
#### 'pyface.Workbench' interface #########################################
# The factory that is used to create workbench windows.
window_factory = WorkbenchWindow
#### 'Workbench' interface ################################################
# The application that the workbench is part of.
application = Instance(IApplication)
# Should the user be prompted before exiting the workbench?
prompt_on_exit = Delegate('_preferences')
#### Private interface ####################################################
# The workbench preferences.
_preferences = Instance(WorkbenchPreferences, ())
###########################################################################
# Private interface.
###########################################################################
def _exiting_changed(self, event):
""" Called when the workbench is exiting. """
if self.prompt_on_exit:
answer = self.active_window.confirm(
"Exit %s?" % self.active_window.title, "Confirm Exit"
)
if answer != YES:
event.veto = True
return
#### EOF ######################################################################
|