traitsui.key_bindings module

Defines KeyBinding and KeyBindings classes, which manage the mapping of keystroke events into method calls on controller objects that are supplied by the application.

traitsui.key_bindings.Binding = Str(editor=KeyBindingEditor())

Trait definition for key bindings

class traitsui.key_bindings.KeyBinding[source]

Bases: traits.has_traits.HasStrictTraits

Binds one or two keystrokes to a method.

binding1 = Binding

First key binding

binding2 = Binding

Second key binding

clear_binding(binding)[source]
description = Str()

Description of what application function the method performs

match(binding)[source]
method_name = Str()

Name of controller method the key is bound to

owner = Instance("KeyBindings")

KeyBindings object that “owns” the KeyBinding

class traitsui.key_bindings.KeyBindings(*bindings, **traits)[source]

Bases: traits.has_traits.HasPrivateTraits

A set of key bindings.

bindings = List(Instance(KeyBinding))

Set of defined key bindings (redefined dynamically)

children = List(transient=True)

The child KeyBindings of this object (if any):

clone(**traits)[source]

Returns a clone of the KeyBindings object.

controllers = List(transient=True)

The (optional) list of controllers associated with this KeyBindings object. The controllers may also be provided with the ‘do’ method:

dispose()[source]

Dispose of the object.

do(event, controllers=[], *args, **kw)[source]

Processes a keyboard event.

edit()[source]

Edits a possibly hierarchical set of KeyBindings.

merge(key_bindings)[source]

Merges another set of key bindings into this set.

parent = Instance("KeyBindings", transient=True)

The ‘parent’ KeyBindings object of this one (if any):

prefix = Str()

Optional prefix to add to each method name

root = Property(observe="parent")

The root of the KeyBindings tree this object is part of:

suffix = Str()

Optional suffix to add to each method name

class traitsui.key_bindings.KeyBindingsHandler(model=None, **metadata)[source]

Bases: traitsui.handler.ModelView

key_binding_for(binding, key_name)[source]

Returns the current binding for a specified key (if any).