Replies: 4 comments
-
There's many widgets in Textual that don't show all the bindings, to avoid the footer becoming too cluttered. You can easily show the bindings you want by sub-classing the widget. from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Footer, Tab, Tabs
class MyTabs(Tabs):
BINDINGS = [
Binding("left", "previous_tab", "Previous tab", show=True),
Binding("right", "next_tab", "Next tab", show=True),
]
class ExampleApp(App):
def compose(self) -> ComposeResult:
yield MyTabs(
Tab("First tab", id="one"),
Tab("Second tab", id="two"),
)
yield Footer()
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
-
Thanks! Subclassing seems trickier since I'm actually using a Do you have any suggestions here? |
Beta Was this translation helpful? Give feedback.
-
Ah, yes that is more tricky. (And adding an option to Tabs wouldn't solve this either.) You might find this discussion helpful - it sounds like the Textual maintainers do plan to revisit the way that users can discover bindings. |
Beta Was this translation helpful? Give feedback.
-
Moving this over to "Ideas". As Tom points out, the whole issue of bindings is something we'll be revisiting in the future. Meanwhile though, while I'd never advocate for diving into internals as a long-term solution, you could do something like this if you want those particular keys displayed in the footer: from dataclasses import replace
from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Footer, Label, Tabs
class TabNavFooterApp(App[None]):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("One"):
yield Label("One")
with TabPane("Two"):
yield Label("Two")
yield Footer()
def on_mount(self) -> None:
tab_keys = self.query_one(Tabs)._bindings.keys
tab_keys["left"] = replace(tab_keys["left"], show=True)
tab_keys["right"] = replace(tab_keys["right"], show=True)
if __name__ == "__main__":
TabNavFooterApp().run() |
Beta Was this translation helpful? Give feedback.
-
left
andright
bindings forTabs
have hardcodedshow=False
, making it so the bindings never appear inFooter
widgets.textual/src/textual/widgets/_tabs.py
Lines 207 to 210 in f02cde2
Adding a
show: bool
argument toTabs
would be nice to enable customizing this behavior.Beta Was this translation helpful? Give feedback.
All reactions