[Python] Correct selector to target a 'Textual' SelectionList selected items' text?

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Textual SelectionList in my Python console app:

    ...
    yield SelectionList[str](
    *tuple(self.selection_items),
    id="mylist")
    ...


    In my associated .tcss (Textual CSS) how would I target the text of a selected item? I'd like all selected items to have a different text colour.

    Interpreting the source of SelectionList, OptionList and ToggleButton I've tried a variety of selectors targeting the -on variant of the ToggleButton child of the SelectionList component (globally and via an #mylist id selector, and while I can change the colour for all items I'm unable to restrict it to just the selected ones.

    Continue reading...

Compartilhe esta Página