Skip to content

Triggering ListView.Selected #1567

Answered by davep
Gabe-Pankoski asked this question in Q&A
Jan 15, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

The event handler for the ListView highlight message should be on_list_view_highlighted -- note the _ in list_view. One of the rules for the handler name that is looked for is CamelCase gets turned into snake_case.

Here's a little standalone variation on what you've got above that will show the events in a TextLog:

import os

from textual.app        import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets    import Header, Footer, ListView, ListItem, TextLog, Label
from textual.reactive   import reactive

class FileReader( App[ None ] ):

    CSS = """
    ListView {
        width: 1fr;
    }
    TextLog {
        width: 1fr;
    }
    """

    files = reac…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Gabe-Pankoski
Comment options

@davep
Comment options

Answer selected by davep
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 #1566 on January 15, 2023 09:17.