mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Adding example for list itemm
This commit is contained in:
13
docs/examples/widgets/list_view.css
Normal file
13
docs/examples/widgets/list_view.css
Normal file
@@ -0,0 +1,13 @@
|
||||
Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
ListView {
|
||||
width: 30;
|
||||
height: auto;
|
||||
margin: 2 2;
|
||||
}
|
||||
|
||||
Label {
|
||||
padding: 1 2;
|
||||
}
|
||||
17
docs/examples/widgets/list_view.py
Normal file
17
docs/examples/widgets/list_view.py
Normal 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()
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user