Last active
March 6, 2024 16:55
-
-
Save paulrobello/5ba0d5a636fbef0a9ff52afeabd43d28 to your computer and use it in GitHub Desktop.
Textual Hidden ListItem Bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from textual.app import App, ComposeResult | |
from textual.widgets import Header, Footer, Log, Label, ListView, ListItem | |
from textual.containers import Horizontal | |
class ListApp(App[None]): | |
def compose(self) -> ComposeResult: | |
yield Header(show_clock=True) | |
with Footer(): | |
yield Label("Use arrow keys to navigate. Hidden items are still selected") | |
with Horizontal(): | |
with ListView(): | |
for i in range(10): | |
li = ListItem() | |
li.mount(Label(f"Item {i}")) | |
li.display = i % 2 == 0 | |
yield li | |
yield Log() | |
def on_list_view_highlighted(self, event: ListView.Highlighted) -> None: | |
self.query_one(Log).write_line(f"Highlighted: {event.item.query_one(Label).renderable}") | |
if __name__ == "__main__": | |
ListApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment