mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
27 lines
812 B
Python
27 lines
812 B
Python
from textual.app import App, ComposeResult
|
|
from textual.widgets import ListView, ListItem, Label
|
|
|
|
|
|
class MyListView(ListView):
|
|
def compose(self) -> ComposeResult:
|
|
"""Compose the child widgets."""
|
|
for n in range(20):
|
|
yield ListView(Label(f"This is item {n}"))
|
|
|
|
|
|
class ListViewApp(App[None]):
|
|
"""ListView test app."""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
"""Compose the child widgets."""
|
|
yield MyListView()
|
|
|
|
|
|
async def test_inherited_list_view() -> None:
|
|
"""A self-populating inherited ListView should work as normal."""
|
|
async with ListViewApp().run_test() as pilot:
|
|
await pilot.press("tab")
|
|
assert pilot.app.query_one(MyListView).index == 0
|
|
await pilot.press("down")
|
|
assert pilot.app.query_one(MyListView).index == 1
|