From 9b2921ae24829395193a45e34b0543c07db7e5c4 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 27 Feb 2024 13:57:05 +0000 Subject: [PATCH] :sparkles: Example for https://github.com/Textualize/textual/issues/4224 --- leaky_select.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 leaky_select.py diff --git a/leaky_select.py b/leaky_select.py new file mode 100644 index 0000000..5c1e67d --- /dev/null +++ b/leaky_select.py @@ -0,0 +1,22 @@ +"""Example for https://github.com/Textualize/textual/issues/4224""" + +from textual import on +from textual.app import App, ComposeResult +from textual.widgets import Log, OptionList, Select + + +class LeakySelectApp(App[None]): + def compose(self) -> ComposeResult: + yield Log() + yield OptionList(*(f"This is option {n}" for n in range(10))) + yield Select[int](((f"This is selection {n}", n) for n in range(10))) + + @on(OptionList.OptionHighlighted) + def log_some_option(self, event: OptionList.OptionHighlighted) -> None: + self.query_one(Log).write_line(f"{event}") + + +if __name__ == "__main__": + LeakySelectApp().run() + +### leaky_select.py ends here