Adding example for list itemm

This commit is contained in:
Darren Burns
2022-11-21 15:12:36 +00:00
parent cbbfcb9a2c
commit eafb9eca8e
3 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
Screen {
align: center middle;
}
ListView {
width: 30;
height: auto;
margin: 2 2;
}
Label {
padding: 1 2;
}

View File

@@ -0,0 +1,17 @@
from textual.app import App, ComposeResult
from textual.widgets import ListView, ListItem, Label, Footer
class ListViewExample(App):
def compose(self) -> ComposeResult:
yield ListView(
ListItem(Label("One")),
ListItem(Label("Two")),
ListItem(Label("Three")),
)
yield Footer()
app = ListViewExample(css_path="list_view.css")
if __name__ == "__main__":
app.run()

View File

@@ -15,7 +15,10 @@ class ListItem(Widget, can_focus=False):
ListItem > Widget :hover {
background: $boost;
}
ListItem.--highlight {
ListView ListItem.--highlight {
background: $accent 50%;
}
ListView:focus ListItem.--highlight {
background: $accent;
}
ListItem > Widget {