textual
textual copied to clipboard
Dynamic bindings update
We need a system to allow for "dynamic bindings" in a declarative manner.
We currently allow for the inspection of bindings to generate a footer, but there is currently no way of updating those bindings once created.
Bindings should be associated with actions. Actions will grow a decorator that exposes parameters such as show, active and description. This decorator creates watchers for those reactives which ultimately update the footer, via a signal.
Here's a rough sketch of the interface:
class MyWidget(Widget):
BINDINGS = [
Binding("s", show_feature)
]
feature_shown = reactive(False)
feature_description = reactive("Do a thing")
@action(show=MyWidget.feature_shown, description=MyWidget.feature_description)
def show_feature(self):
...
- Note that we now have an action decorator to create actions, but we should continue to support the
action_naming convention. - We will need an update to the Footer widget to support this. Maybe look to Toolong for inspiration there.
- I think we might want to display keys in a less verbose manner, i.e.
^frather thanctrl+f
This is a fairly involved task, because it does touch a lot of areas. But a big improvement I think!
Closely related/dupe of: https://github.com/Textualize/textual/issues/2269