enable.base_tool module¶
Defines the base class for all Chaco tools. See docs/event_handling.txt for an overview of how event handling works in Chaco.
-
class
enable.base_tool.
BaseTool
(component=None, **traits)[source]¶ Bases:
enable.interactor.Interactor
The base class for Chaco tools.
Tools are not Enable components, but they can draw. They do not participate in layout, but are instead attached to a Component, which dispatches methods to the tool and calls the tools’ draw() method.
See docs/event_handling.txt for more information on how tools are structured.
-
class
enable.base_tool.
KeySpec
(key, *modifiers, **kwmods)[source]¶ Bases:
object
Creates a key specification to facilitate tools interacting with the keyboard. A tool can declare either a class attribute:
magic_key = KeySpec("Right", "control", ignore=['shift'])
or a trait:
magic_key = Instance(KeySpec, args=("Right", "control"), kw={'ignore': ['shift']})
and then check to see if the key was pressed by calling:
if self.magic_key.match(event): # do stuff...
The names of the keys come from Enable, so both examples above are specifying the user pressing Ctrl + Right_arrow with Alt not pressed and Shift either pressed or not.