Skip to content

There is App.bind but no App.unbind #4644

Answered by davep
arcivanov asked this question in Q&A
Discussion options

You must be logged in to vote

If you want specific bindings to only be available in a certain tab pane, or even the same key but bound in different ways in different tab panes, the usual way would be to make those bindings part of the pane. For example, here's 3 different tabs in a TabbedContent, each one has a binding for F1, but each one does different things:

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Footer, TabbedContent, TabPane, OptionList

class FooTab(TabPane):

    BINDINGS = [
        Binding("f1", "gndn", "Does a Foo"),
    ]

    def compose(self) -> ComposeResult:
        yield OptionList(*[f"Foo {n}" for n in range(100)])


class BarTab(Tab…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@arcivanov
Comment options

@arcivanov
Comment options

@arcivanov
Comment options

@davep
Comment options

@arcivanov
Comment options

Answer selected by arcivanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants