File: action_controller.py

package info (click to toggle)
python-pyface 6.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,756 kB
  • sloc: python: 39,728; makefile: 79
file content (37 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download | duplicates (4)
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
""" The action controller for workbench menu and tool bars. """


# Enthought library imports.
from pyface.action.api import ActionController
from pyface.workbench.api import WorkbenchWindow
from traits.api import HasTraits, Instance


class ActionController(ActionController):
    """ The action controller for workbench menu and tool bars.

    The controller is used to 'hook' the invocation of every action on the menu
    and tool bars. This is done so that additional (and workbench specific)
    information can be added to action events. Currently, we attach a reference
    to the workbench window.

    """

    #### 'ActionController' interface #########################################

    # The workbench window that this is the controller for.
    window = Instance(WorkbenchWindow)

    ###########################################################################
    # 'ActionController' interface.
    ###########################################################################

    def perform(self, action, event):
        """ Control an action invocation. """

        # Add a reference to the window and the application to the event.
        event.window = self.window

        return action.perform(event)

#### EOF ######################################################################