how to add and fill a TabPane to an existing TabbedContent #5291
-
In the demo application, the widget description and the api documentation, Unfortunately, within my own application, I was not able to add and define a new profiles = [ 'Tab1', 'Tab2', 'Tab3' ]
for _profile in profiles:
_TabPane = _TabbedContent.add_pane(
pane=TabPane(
title=_profile,
name=_profile,
id=_profile.lower(),
? children=Static("<description>", classes="profile",)
)
) Is there a way to dynamically add and fill further Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
It looks like you are pretty much there already, unless I've misunderstood your question. Here's a quick example: from textual.app import App, ComposeResult
from textual.widgets import Footer, Static, TabbedContent, TabPane
class ExampleApp(App):
BINDINGS = [
("a", "add_panes", "Add panes"),
]
def compose(self) -> ComposeResult:
yield TabbedContent()
yield Footer()
def action_add_panes(self) -> None:
tabbed_content = self.query_one(TabbedContent)
for i in range(1, 4):
tabbed_content.add_pane(
TabPane(
f"Tab{i}",
Static(f"Tab{i} content"),
)
)
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
-
Thanks My "mistake" was to use the parameters of As this seems to be a general concept for documentation, where do I find notes about how to use a parameter which is written as e.g. |
Beta Was this translation helpful? Give feedback.
It looks like you are pretty much there already, unless I've misunderstood your question.
Here's a quick example: