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:
File diff suppressed because one or more lines are too long
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()
|
||||
@@ -256,3 +256,7 @@ def test_disabled_widgets(snap_compare):
|
||||
|
||||
def test_focus_component_class(snap_compare):
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "focus_component_class.py", press=["tab"])
|
||||
|
||||
|
||||
def test_line_api_scrollbars(snap_compare):
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "line_api_scrollbars.py", press=["_"])
|
||||
|
||||
@@ -46,6 +46,7 @@ async def test_tree_node_selected_message() -> None:
|
||||
"""Selecting a node should result in a selected message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter")
|
||||
await pilot.pause()
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeSelected"]
|
||||
|
||||
|
||||
@@ -54,6 +55,7 @@ async def test_tree_node_selected_message_no_auto() -> None:
|
||||
async with TreeApp().run_test() as pilot:
|
||||
pilot.app.query_one(MyTree).auto_expand = False
|
||||
await pilot.press("enter")
|
||||
await pilot.pause()
|
||||
assert pilot.app.messages == ["NodeSelected"]
|
||||
|
||||
|
||||
@@ -61,6 +63,7 @@ async def test_tree_node_expanded_message() -> None:
|
||||
"""Expanding a node should result in an expanded message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("space")
|
||||
await pilot.pause()
|
||||
assert pilot.app.messages == ["NodeExpanded"]
|
||||
|
||||
|
||||
@@ -68,6 +71,7 @@ async def test_tree_node_collapsed_message() -> None:
|
||||
"""Collapsing a node should result in a collapsed message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("space", "space")
|
||||
await pilot.pause()
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeCollapsed"]
|
||||
|
||||
|
||||
@@ -75,4 +79,5 @@ async def test_tree_node_highlighted_message() -> None:
|
||||
"""Highlighting a node should result in a highlighted message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter", "down")
|
||||
await pilot.pause()
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeSelected", "NodeHighlighted"]
|
||||
|
||||
Reference in New Issue
Block a user