mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Container
|
||||
from textual.containers import ScrollableContainer
|
||||
from textual.widgets import Label
|
||||
|
||||
TEXT = """I must not fear.
|
||||
@@ -14,7 +14,7 @@ Where the fear has gone there will be nothing. Only I will remain.
|
||||
|
||||
class ScrollbarApp(App):
|
||||
def compose(self):
|
||||
yield Container(Label(TEXT * 5), classes="panel")
|
||||
yield ScrollableContainer(Label(TEXT * 5), classes="panel")
|
||||
|
||||
|
||||
app = ScrollbarApp(css_path="scrollbar_size.css")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Container {
|
||||
ScrollableContainer {
|
||||
width: 1fr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Horizontal, Container
|
||||
from textual.containers import Horizontal, ScrollableContainer
|
||||
from textual.widgets import Label
|
||||
|
||||
TEXT = """I must not fear.
|
||||
@@ -15,10 +15,12 @@ Where the fear has gone there will be nothing. Only I will remain.
|
||||
class ScrollbarApp(App):
|
||||
def compose(self):
|
||||
yield Horizontal(
|
||||
Container(Label(TEXT * 5), id="v1"),
|
||||
Container(Label(TEXT * 5), id="v2"),
|
||||
Container(Label(TEXT * 5), id="v3"),
|
||||
ScrollableContainer(Label(TEXT * 5), id="v1"),
|
||||
ScrollableContainer(Label(TEXT * 5), id="v2"),
|
||||
ScrollableContainer(Label(TEXT * 5), id="v3"),
|
||||
)
|
||||
|
||||
|
||||
app = ScrollbarApp(css_path="scrollbar_size2.css")
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
@@ -9,6 +9,6 @@ Label {
|
||||
scrollbar-corner-color: blue;
|
||||
}
|
||||
|
||||
Horizontal > Container {
|
||||
Horizontal > ScrollableContainer {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual.containers import Horizontal, Container
|
||||
from textual.containers import Horizontal, ScrollableContainer
|
||||
from textual.widgets import Label
|
||||
|
||||
TEXT = """I must not fear.
|
||||
@@ -15,9 +15,11 @@ Where the fear has gone there will be nothing. Only I will remain.
|
||||
class ScrollbarApp(App):
|
||||
def compose(self):
|
||||
yield Horizontal(
|
||||
Container(Label(TEXT * 10)),
|
||||
Container(Label(TEXT * 10), classes="right"),
|
||||
ScrollableContainer(Label(TEXT * 10)),
|
||||
ScrollableContainer(Label(TEXT * 10), classes="right"),
|
||||
)
|
||||
|
||||
|
||||
app = ScrollbarApp(css_path="scrollbars.css")
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from rich.align import VerticalCenter
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Horizontal
|
||||
from textual.containers import Horizontal, VerticalScroll
|
||||
from textual.widgets import Button, ContentSwitcher, DataTable, Markdown
|
||||
|
||||
MARKDOWN_EXAMPLE = """# Three Flavours Cornetto
|
||||
@@ -37,7 +39,8 @@ class ContentSwitcherApp(App[None]):
|
||||
|
||||
with ContentSwitcher(initial="data-table"): # (4)!
|
||||
yield DataTable(id="data-table")
|
||||
yield Markdown(MARKDOWN_EXAMPLE, id="markdown")
|
||||
with VerticalScroll(id="markdown"):
|
||||
yield Markdown(MARKDOWN_EXAMPLE)
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
self.query_one(ContentSwitcher).current = event.button.id # (5)!
|
||||
|
||||
Reference in New Issue
Block a user