From f9ea27d331394a069c2349d268c91ef325f4cf92 Mon Sep 17 00:00:00 2001 From: Isaak Buslovich Date: Mon, 20 Nov 2023 19:58:03 +0100 Subject: [PATCH] 3 --- text.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/text.py b/text.py index 9f6b91a..c13902a 100644 --- a/text.py +++ b/text.py @@ -1,16 +1,27 @@ -from textual.app import App, ComposeResult +from textual.app import App from textual.widgets import TabbedContent, TabPane, TextArea class SimpleCLITool(App): - def compose(self) -> ComposeResult: - # Create TabbedContent with two tabs - yield TabbedContent() as tc: - # First Tab - with TabPane("First Tab"): - yield TextArea("This is the content of the first tab. " * 10, auto_width=True) - # Second Tab - with TabPane("Second Tab"): - yield TextArea("This is the content of the second tab. " * 10, auto_width=True) + async def on_mount(self): + # Create TabbedContent with two tabs + tabbed_content = TabbedContent() + + # First Tab with its content + first_tab = TabPane("First Tab") + first_tab_content = TextArea("This is the content of the first tab. " * 10, auto_width=True) + await first_tab.mount(first_tab_content) + + # Second Tab with its content + second_tab = TabPane("Second Tab") + second_tab_content = TextArea("This is the content of the second tab. " * 10, auto_width=True) + await second_tab.mount(second_tab_content) + + # Add tabs to TabbedContent + tabbed_content.add_tab(first_tab, "First Tab") + tabbed_content.add_tab(second_tab, "Second Tab") + + # Dock the TabbedContent into the app's view + await self.view.dock(tabbed_content) SimpleCLITool.run(log="textual.log")