File: workbench.py

package info (click to toggle)
python-envisageplugins 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,616 kB
  • ctags: 1,970
  • sloc: python: 7,047; makefile: 11; sh: 11; lisp: 1
file content (58 lines) | stat: -rw-r--r-- 1,826 bytes parent folder | download | duplicates (2)
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 ######################################################################