textual icon indicating copy to clipboard operation
textual copied to clipboard

Dynamic bindings update

Open willmcgugan opened this issue 1 year ago • 1 comments

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. ^f rather than ctrl+f

This is a fairly involved task, because it does touch a lot of areas. But a big improvement I think!

willmcgugan avatar Feb 19 '24 11:02 willmcgugan

Closely related/dupe of: https://github.com/Textualize/textual/issues/2269

darrenburns avatar Feb 27 '24 13:02 darrenburns

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

github-actions[bot] avatar Jul 11 '24 16:07 github-actions[bot]