mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
updated list view
This commit is contained in:
@@ -55,8 +55,22 @@ The Tree control forms the foundation of the [DirectoryTree](../../widgets/direc
|
|||||||
|
|
||||||
We have a new list view control to navigate and select items in a list. Items can be widgets themselves, which makes this a great platform for building more sophisticated controls.
|
We have a new list view control to navigate and select items in a list. Items can be widgets themselves, which makes this a great platform for building more sophisticated controls.
|
||||||
|
|
||||||
```{.textual path="docs/examples/widgets/list_view.py"}
|
=== "Output"
|
||||||
```
|
|
||||||
|
```{.textual path="docs/examples/widgets/list_view.py"}
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "list_view.py"
|
||||||
|
|
||||||
|
```python
|
||||||
|
--8<-- "docs/examples/widgets/list_view.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "list_view.css"
|
||||||
|
|
||||||
|
```sass
|
||||||
|
--8<-- "docs/examples/widgets/list_view.css"
|
||||||
|
```
|
||||||
|
|
||||||
## Placeholder
|
## Placeholder
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ from textual.widgets import ListView, ListItem, Label, Footer
|
|||||||
|
|
||||||
|
|
||||||
class ListViewExample(App):
|
class ListViewExample(App):
|
||||||
|
|
||||||
|
CSS_PATH = "list_view.css"
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield ListView(
|
yield ListView(
|
||||||
ListItem(Label("One")),
|
ListItem(Label("One")),
|
||||||
@@ -12,6 +15,6 @@ class ListViewExample(App):
|
|||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
|
|
||||||
app = ListViewExample(css_path="list_view.css")
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
app = ListViewExample()
|
||||||
app.run()
|
app.run()
|
||||||
|
|||||||
@@ -21,10 +21,16 @@ The example below shows an app with a simple `ListView`.
|
|||||||
--8<-- "docs/examples/widgets/list_view.py"
|
--8<-- "docs/examples/widgets/list_view.py"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "list_view.css"
|
||||||
|
|
||||||
|
```sass
|
||||||
|
--8<-- "docs/examples/widgets/list_view.css"
|
||||||
|
```
|
||||||
|
|
||||||
## Reactive Attributes
|
## Reactive Attributes
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|---------|-------|---------|---------------------------------|
|
| ------- | ----- | ------- | ------------------------------- |
|
||||||
| `index` | `int` | `0` | The currently highlighted index |
|
| `index` | `int` | `0` | The currently highlighted index |
|
||||||
|
|
||||||
## Messages
|
## Messages
|
||||||
@@ -40,7 +46,7 @@ click on a list item.
|
|||||||
#### Attributes
|
#### Attributes
|
||||||
|
|
||||||
| attribute | type | purpose |
|
| attribute | type | purpose |
|
||||||
|-----------|------------|--------------------------------|
|
| --------- | ---------- | ------------------------------ |
|
||||||
| `item` | `ListItem` | The item that was highlighted. |
|
| `item` | `ListItem` | The item that was highlighted. |
|
||||||
|
|
||||||
### Selected
|
### Selected
|
||||||
@@ -54,7 +60,7 @@ or by clicking on it.
|
|||||||
#### Attributes
|
#### Attributes
|
||||||
|
|
||||||
| attribute | type | purpose |
|
| attribute | type | purpose |
|
||||||
|-----------|------------|-----------------------------|
|
| --------- | ---------- | --------------------------- |
|
||||||
| `item` | `ListItem` | The item that was selected. |
|
| `item` | `ListItem` | The item that was selected. |
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +74,7 @@ are changed (e.g. a child is added, or the list is cleared).
|
|||||||
#### Attributes
|
#### Attributes
|
||||||
|
|
||||||
| attribute | type | purpose |
|
| attribute | type | purpose |
|
||||||
|------------|------------------|---------------------------|
|
| ---------- | ---------------- | ------------------------- |
|
||||||
| `children` | `list[ListItem]` | The new ListView children |
|
| `children` | `list[ListItem]` | The new ListView children |
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user