textual.binding
This module contains the Binding
class and related objects.
See bindings in the guide for details.
ActiveBinding
¶
Bases: NamedTuple
Information about an active binding (returned from active_bindings).
enabled
instance-attribute
¶
Is the binding enabled? (enabled bindings are typically rendered dim)
Binding
dataclass
¶
The configuration of a key binding.
BindingsMap
¶
BindingsMap(bindings=None)
Manage a set of bindings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Iterable[BindingType] | None
|
An optional set of initial bindings. |
None
|
Note
The iterable of bindings can contain either a Binding
instance, or a tuple of 3 values mapping to the first three
properties of a Binding
.
bind
¶
bind(
keys,
action,
description="",
show=True,
key_display=None,
priority=False,
)
Bind keys to an action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
The keys to bind. Can be a comma-separated list of keys. |
required |
|
str
|
The action to bind the keys to. |
required |
|
str
|
An optional description for the binding. |
''
|
|
bool
|
A flag to say if the binding should appear in the footer. |
True
|
|
str | None
|
Optional string to display in the footer for the key. |
None
|
|
bool
|
Is this a priority binding, checked form app down to focused widget? |
False
|
merge
classmethod
¶
merge(bindings)
Merge a bindings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Iterable[BindingsMap]
|
A number of bindings. |
required |
Returns:
Type | Description |
---|---|
BindingsMap
|
New |