Files
textual/tests/snapshot_tests/snapshot_apps/line_api_scrollbars.py
Rodrigo Girão Serrão 8565d3cef6 Renamed 'Vertical' to 'VerticalScroll'.
Related issues: #1957.
2023-03-08 18:31:24 +00:00

55 lines
1.1 KiB
Python

from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widget import Widget
from textual.widgets import TextLog
class MyWidget(Widget):
def render(self):
return Text(
"\n".join(f"{n} 0123456789" for n in range(20)),
no_wrap=True,
overflow="hidden",
justify="left",
)
class ScrollViewApp(App):
CSS = """
Screen {
align: center middle;
}
TextLog {
width:13;
height:10;
}
VerticalScroll {
width:13;
height: 10;
overflow: scroll;
overflow-x: auto;
}
MyWidget {
width:13;
height:auto;
}
"""
def compose(self) -> ComposeResult:
yield TextLog()
yield VerticalScroll(MyWidget())
def on_ready(self) -> None:
self.query_one(TextLog).write("\n".join(f"{n} 0123456789" for n in range(20)))
self.query_one(VerticalScroll).scroll_end(animate=False)
if __name__ == "__main__":
app = ScrollViewApp()
app.run()