From af828ed5c0386a6dadb6cdc95d4f438df38436d0 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 29 Nov 2023 20:08:21 +0000 Subject: [PATCH] :sparkles: Examples for https://github.com/Textualize/textual/issues/3781 --- no_children1.py | 11 +++++++++++ no_children2.py | 15 +++++++++++++++ no_children3.py | 13 +++++++++++++ no_children4.py | 14 ++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 no_children1.py create mode 100644 no_children2.py create mode 100644 no_children3.py create mode 100644 no_children4.py diff --git a/no_children1.py b/no_children1.py new file mode 100644 index 0000000..818b1ce --- /dev/null +++ b/no_children1.py @@ -0,0 +1,11 @@ +from textual.app import App, ComposeResult +from textual.widgets import Static + +class NoChildren1(App[None]): + + def compose(self) -> ComposeResult: + with Static(): + yield Static("Hello") + +if __name__ == "__main__": + NoChildren1().run() diff --git a/no_children2.py b/no_children2.py new file mode 100644 index 0000000..ac8a1bf --- /dev/null +++ b/no_children2.py @@ -0,0 +1,15 @@ +from textual.app import App, ComposeResult +from textual.widgets import Static + +class DodgyStatic(Static): + + def compose(self) -> ComposeResult: + yield Static("Hello") + +class NoChildren2(App[None]): + + def compose(self) -> ComposeResult: + yield DodgyStatic() + +if __name__ == "__main__": + NoChildren2().run() diff --git a/no_children3.py b/no_children3.py new file mode 100644 index 0000000..8f3df01 --- /dev/null +++ b/no_children3.py @@ -0,0 +1,13 @@ +from textual.app import App, ComposeResult +from textual.widgets import Static + +class NoChildren1(App[None]): + + def compose(self) -> ComposeResult: + yield Static() + + def on_mount(self) -> None: + self.query_one(Static).mount(Static("Hello")) + +if __name__ == "__main__": + NoChildren1().run() diff --git a/no_children4.py b/no_children4.py new file mode 100644 index 0000000..2b0a748 --- /dev/null +++ b/no_children4.py @@ -0,0 +1,14 @@ +from textual.app import App, ComposeResult +from textual.widget import Widget +from textual.widgets import Static + +class NotACounter(Widget): + ALLOW_CHILDREN = False + +class NoChildren4(App[None]): + + def compose(self) -> ComposeResult: + yield NotACounter(Static("Hello")) + +if __name__ == "__main__": + NoChildren4().run()