mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Fix content width (#1910)
* fix calculation for scrollbars * added snapshot * fix for name change * snapshot * fix for textual colors * remove logs * scrollbar logic * scroll logic * remove dead code * snapshot tests * scrollbar mechanism * tidy * demo tweak * preset window size * no need for repaint * Restore repaint * wait for idle on pause * colors tweak * remove wait for idle * snapshot * small sleep * change stabilizer * debug tweaks * remove debug * remove debug * snapshot test * docstring * changelog * add pause
This commit is contained in:
54
tests/snapshot_tests/snapshot_apps/line_api_scrollbars.py
Normal file
54
tests/snapshot_tests/snapshot_apps/line_api_scrollbars.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from rich.text import Text
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
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;
|
||||
}
|
||||
|
||||
Vertical{
|
||||
width:13;
|
||||
height: 10;
|
||||
overflow: scroll;
|
||||
overflow-x: auto;
|
||||
}
|
||||
MyWidget {
|
||||
width:13;
|
||||
height:auto;
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield TextLog()
|
||||
yield Vertical(MyWidget())
|
||||
|
||||
def on_ready(self) -> None:
|
||||
self.query_one(TextLog).write("\n".join(f"{n} 0123456789" for n in range(20)))
|
||||
self.query_one(Vertical).scroll_end(animate=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = ScrollViewApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user