Skip to content
Discussion options

You must be logged in to vote

I suspect there's a bit of confusion here about what a ListItem is. A ListItem is intended to be a container for other widgets. So, if you look at the example code for a ListView you'll see that each ListItem contains a Label:

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


class ListViewExample(App):

    CSS_PATH = "list_view.css"

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


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

Running the above code (…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@davep
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by WantToLearnJapanese
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1731 on February 07, 2023 08:35.