Merge branch 'main' of github.com:Textualize/textual into list-view

This commit is contained in:
Darren Burns
2022-11-18 16:35:50 +00:00
45 changed files with 685 additions and 283 deletions

1
docs/api/label.md Normal file
View File

@@ -0,0 +1 @@
::: textual.widgets.Label

View File

@@ -2,3 +2,15 @@ willmcgugan:
name: Will McGugan
description: CEO / code-monkey
avatar: https://github.com/willmcgugan.png
darrenburns:
name: Darren Burns
description: Code-monkey
avatar: https://github.com/darrenburns.png
davep:
name: Dave Pearson
description: Code-monkey
avatar: https://github.com/davep.png
rodrigo:
name: Rodrigo Girão Serrão
description: Code-monkey
avatar: https://github.com/rodrigogiraoserrao.png

View File

@@ -0,0 +1,12 @@
from textual.app import App, ComposeResult
from textual.widgets import Label
class LabelApp(App):
def compose(self) -> ComposeResult:
yield Label("Hello, world!")
if __name__ == "__main__":
app = LabelApp()
app.run()

View File

@@ -25,7 +25,7 @@ textual run my_app.py
The `run` sub-command will first look for a `App` instance called `app` in the global scope of your Python file. If there is no `app`, it will create an instance of the first `App` class it finds and run that.
Alternatively, you can add the name of an `App` instance or class after a colon to run a specific app in the Python file. Here's an example:
Alternatively, you can add the name of an `App` instance or class after a colon to run a specific app in the Python file. Here's an example:
```bash
textual run my_app.py:alternative_app
@@ -119,6 +119,6 @@ class LogApp(App):
self.log(self.tree)
if __name__ == "__main__":
LogApp.run()
LogApp().run()
```

33
docs/widgets/label.md Normal file
View File

@@ -0,0 +1,33 @@
# Label
A widget which displays static text, but which can also contain more complex Rich renderables.
- [ ] Focusable
- [ ] Container
## Example
The example below shows how you can use a `Label` widget to display some text.
=== "Output"
```{.textual path="docs/examples/widgets/label.py"}
```
=== "label.py"
```python
--8<-- "docs/examples/widgets/label.py"
```
## Reactive Attributes
This widget has no reactive attributes.
## Messages
This widget sends no messages.
## See Also
* [Label](../api/label.md) code reference

View File

@@ -1,14 +1,14 @@
# Static
A widget which displays static content.
Can be used for simple text labels, but can also contain more complex Rich renderables.
Can be used for Rich renderables and can also for the base for other types of widgets.
- [ ] Focusable
- [x] Container
- [ ] Container
## Example
The example below shows how you can use a `Static` widget as a simple text label.
The example below shows how you can use a `Static` widget as a simple text label (but see [Label](./label.md) as a way of displaying text).
=== "Output"
@@ -32,3 +32,4 @@ This widget sends no messages.
## See Also
* [Static](../api/static.md) code reference
* [Label](./label.md)