This commit is contained in:
Isaak Buslovich 2023-11-20 19:55:08 +01:00
parent b527fb2add
commit 0c9926e2dd

27
text.py
View File

@ -1,21 +1,16 @@
from textual.app import App from textual.app import App, ComposeResult
from textual.widgets import ScrollView, TabView, Tab from textual.widgets import TabbedContent, TabPane, TextArea
class SimpleCLITool(App): class SimpleCLITool(App):
async def on_mount(self): def compose(self) -> ComposeResult:
# Create TabView with two tabs # Create TabbedContent with two tabs
tabs = TabView( yield TabbedContent() as tc:
tabs=[ # First Tab
Tab("First Tab", content=ScrollView(auto_width=True)), with TabPane("First Tab"):
Tab("Second Tab", content=ScrollView(auto_width=True)) yield TextArea("This is the content of the first tab. " * 10, auto_width=True)
]
)
# Update content for each tab # Second Tab
tabs.tabs[0].content.update("This is the content of the first tab. " * 10) with TabPane("Second Tab"):
tabs.tabs[1].content.update("This is the content of the second tab. " * 10) yield TextArea("This is the content of the second tab. " * 10, auto_width=True)
# Dock the tabs into the app's view
await self.view.dock(tabs)
SimpleCLITool.run(log="textual.log") SimpleCLITool.run(log="textual.log")