File: action_controller.py

package info (click to toggle)
python-traitsgui 3.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,276 kB
  • sloc: python: 12,190; makefile: 85; sh: 5
file content (37 lines) | stat: -rw-r--r-- 1,380 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
""" The action controller for workbench menu and tool bars. """


# Enthought library imports.
from enthought.pyface.action.api import ActionController
from enthought.pyface.workbench.api import WorkbenchWindow
from enthought.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 ######################################################################