Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the ListView documentation by explaining the ListItem #4454

Closed
TomJGooding opened this issue Apr 27, 2024 · 3 comments
Closed

Improve the ListView documentation by explaining the ListItem #4454

TomJGooding opened this issue Apr 27, 2024 · 3 comments

Comments

@TomJGooding
Copy link
Contributor

TomJGooding commented Apr 27, 2024

I think the ListView documentation could be improved by explaining the ListItem.

Here's a simple example adapted from the docs. I don't think it is clear from the documentation how you might get the Label text when a ListItem is highlighted:

from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Label, ListItem, ListView


class ListViewExample(App):
    CSS = """
    Screen {
        align: center middle;
    }

    ListView {
        width: 30;
        height: auto;
    }
    """

    def compose(self) -> ComposeResult:
        yield ListView(
            ListItem(Label("One")),
            ListItem(Label("Two")),
            ListItem(Label("Three")),
        )

    @on(ListView.Highlighted)
    def notify_highlighted_label(self, event: ListView.Highlighted) -> None:
        highlighted = event.item
        self.notify(str(highlighted))


if __name__ == "__main__":
    app = ListViewExample()
    app.run()
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@TomJGooding TomJGooding changed the title Improve the ListItem documentation by explaining the ListItem Improve the ListView documentation by explaining the ListItem Apr 27, 2024
@TomJGooding
Copy link
Contributor Author

TomJGooding commented May 1, 2024

Actually on reflection I don't think this is really necessary. ListItem is just a widget and querying the children is already covered elsewhere in the docs.

Copy link

github-actions bot commented May 1, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant