From 043b2aaf3e44b5aa1237f39c09a18a98bef635bd Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 12 Oct 2023 09:51:55 +0100 Subject: [PATCH] :sparkles: Add an illustration for https://github.com/Textualize/textual/issues/3517 --- loading_test.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 loading_test.py diff --git a/loading_test.py b/loading_test.py new file mode 100644 index 0000000..56ca1c1 --- /dev/null +++ b/loading_test.py @@ -0,0 +1,38 @@ +"""https://github.com/Textualize/textual/issues/3517""" + +from textual.app import App, ComposeResult +from textual.containers import Grid, Container + +class BusyBox(Container, can_focus=True): + + DEFAULT_CSS = """ + BusyBox { + border: panel red; + } + BusyBox:focus { + border: panel green; + } + """ + + def __init__(self, number: int) -> None: + super().__init__() + self.border_title = f"Busy box {number}" + self.loading = bool(number % 3) + +class LoadingApp(App[None]): + + CSS = """ + Grid { + grid-size: 4; + } + """ + + def compose(self) -> ComposeResult: + with Grid(): + for n in range(16): + yield BusyBox(n) + +if __name__ == "__main__": + LoadingApp().run() + +### loading_test.py ends here