enable.tools.pyface.context_menu_tool module

This is a minimum example for adding a context menu to plot.

class enable.tools.pyface.context_menu_tool.ContextMenuTool(component=None, **traits)[source]

Bases: enable.base_tool.BaseTool

Pops up a context menu when the component receives a right click

controller = Instance(ActionController)

an optional ActionController

is_showable(x, y)[source]

Returns whether the (x, y) position is OK for showing the menu

By default checks that the point is in the component. Subclasses can override to provide more refined hit-testing.

menu_manager = Instance(MenuManager)

the pyface action MenuManager instance

normal_right_down(event)[source]

Handles the right mouse button being pressed.

show_menu(event)[source]

Create the toolkit menu and show it

This method also makes the enable event available to the controller.

class enable.tools.pyface.context_menu_tool.EnableActionController[source]

Bases: pyface.action.action_controller.ActionController

An action controller that keeps a reference to the enable event that triggered the action.

enable_event = Any

the enable event which triggered the popup menu

perform(action, event)[source]

Control an action invocation

We make the original enable event available to the action by adding it to the pyface event.