From f510b847f053fdc584c00c2ffb425e52fec54413 Mon Sep 17 00:00:00 2001 From: Isaak Buslovich Date: Mon, 20 Nov 2023 20:14:49 +0100 Subject: [PATCH] Fix --- text.py | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/text.py b/text.py index 51e9fa8..e7157fc 100644 --- a/text.py +++ b/text.py @@ -1,32 +1,14 @@ -from textual.app import App -from textual.widgets import TabbedContent, TabPane, TextArea +from textual.app import App, ComposeResult +from textual.widgets import Markdown, TabbedContent, TabPane -class SimpleCLITool(App): +class TabbedApp(App): + def compose(self) -> ComposeResult: + with TabbedContent(initial="tab1"): + with TabPane("First Tab", id="tab1"): + yield Markdown("This is the content of the first tab.") + with TabPane("Second Tab", id="tab2"): + yield Markdown("This is the content of the second tab.") - 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() - first_tab_content.value = "This is the content of the first tab. " * 10 - await first_tab.mount(first_tab_content) - - # Second Tab with its content - second_tab = TabPane("Second Tab") - second_tab_content = TextArea() - second_tab_content.value = "This is the content of the second tab. " * 10 - 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) - -# Create an instance of the app and run it if __name__ == "__main__": - app = SimpleCLITool() + app = TabbedApp() app.run()