Accessing inner ContentTabs object from TabbedContent #4808
-
Hi, I'm trying to create a TUI with a TabbedContent and some Input widgets, when the Input is focused I can't switch between tabs anymore with arrows, so my first idea was to change the focus back to the container of my tabs, however, focusing TabbedContent doesn't work. After some debugging I've noticed that the previously focused widget was ContentTabs, but I don't see a function nor attribute to access it. In the source code I see calls Edit: Nevermind, I can access it by importing the private module from textual.app import App, ComposeResult
from textual.widgets import Footer, TabbedContent, Markdown, TabPane, Input
class TestApp(App):
BINDINGS = [
("q", "quit", "Quit de app"),
("u", "first", "First field"),
("r", "second", "Second field"),
]
def compose(self) -> ComposeResult:
with TabbedContent(classes="box", id="tabcont"):
with TabPane("Tab 1"):
yield Markdown("# Pane 1")
yield Input(placeholder="field 1")
yield Input(placeholder="field 2")
with TabPane("Tab 2"):
yield Markdown("# Pane 2")
yield Footer()
def on_key(self, event):
if event.key == "escape":
prev = self.app.screen.focus_previous()
print(prev)
print(type(prev))
tc = self.query_one(TabbedContent)
print(tc)
print(type(tc))
if __name__ == '__main__':
app = TestApp()
app.run() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
ContentTabs
is now publicly exported after Textual v0.73.0 - see #4765