Document Static widget

This commit is contained in:
Darren Burns
2022-10-04 13:35:56 +01:00
parent 48ae4c87b1
commit 8225b43ac1
3 changed files with 47 additions and 2 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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.