From 8225b43ac173cbd364f7cdce8e75fd977ccea2e7 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 4 Oct 2022 13:35:56 +0100 Subject: [PATCH] Document Static widget --- docs/examples/widgets/static.py | 12 ++++++++++++ docs/widgets/static.md | 32 ++++++++++++++++++++++++++++++++ src/textual/widgets/_static.py | 5 +++-- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 docs/examples/widgets/static.py diff --git a/docs/examples/widgets/static.py b/docs/examples/widgets/static.py new file mode 100644 index 000000000..691334e4a --- /dev/null +++ b/docs/examples/widgets/static.py @@ -0,0 +1,12 @@ +from textual.app import App, ComposeResult +from textual.widgets import Static + + +class StaticApp(App): + def compose(self) -> ComposeResult: + yield Static("Hello, world!") + + +if __name__ == "__main__": + app = StaticApp() + app.run() diff --git a/docs/widgets/static.md b/docs/widgets/static.md index 0be60b558..e37d96110 100644 --- a/docs/widgets/static.md +++ b/docs/widgets/static.md @@ -1 +1,33 @@ # Static + +## Description + +A widget which displays a static renderable content. +Can be used for simple text labels, but can also contain more complex Rich renderables. + +## Example + +The example below shows how you can use a `Static` widget as a simple text label. + +=== "Output" + + ```{.textual path="docs/examples/widgets/static.py"} + ``` + +=== "static.py" + + ```python + --8<-- "docs/examples/widgets/static.py" + ``` + +## Reactive Attributes + +This widget has no reactive attributes. + +## Messages + +This widget sends no messages. + +## See Also + +* [Static](../reference/static.md) code reference diff --git a/src/textual/widgets/_static.py b/src/textual/widgets/_static.py index 7e10a8a1b..3b91969ef 100644 --- a/src/textual/widgets/_static.py +++ b/src/textual/widgets/_static.py @@ -25,13 +25,14 @@ def _check_renderable(renderable: object): class Static(Widget): - """A widget to display simple static content, or use as a base- lass for more complex widgets. + """A widget to display simple static content, or use as a base class for more complex widgets. Args: renderable (RenderableType, optional): A Rich renderable, or string containing console markup. Defaults to "". expand (bool, optional): Rich renderable may expand beyond optimal. Defaults to False. - shrink (bool, optional): Rich renderable may shrink below optional. Defaults to False. + shrink (bool, optional): Rich renderable may shrink below optimal. Defaults to False. + markup (bool, optional): True if markup should be parsed and rendered. Defaults to True. name (str | None, optional): Name of widget. Defaults to None. id (str | None, optional): ID of Widget. Defaults to None. classes (str | None, optional): Space separated list of class names. Defaults to None.