moar docs

This commit is contained in:
Will McGugan
2022-07-30 22:33:55 +01:00
parent 7040d00c7b
commit 99ccbc5eb8
12 changed files with 227 additions and 0 deletions

View File

@@ -17,4 +17,5 @@ class ButtonApp(App):
def handle_pressed(self, event):
self.dark = not self.dark
self.bell()
event.button.label = "Lights ON" if self.dark else "Lights OFF"

View File

@@ -0,0 +1,9 @@
These are the examples from the documentation, used to generate screenshots.
You can run them with the textual CLI.
For example:
```
textual run text_style.py
```

View File

@@ -4,6 +4,9 @@ from textual.widgets import Static
class BorderApp(App):
CSS = """
Screen {
background: white;
}
Screen > Static {
height:5;
content-align: center middle;
@@ -13,14 +16,18 @@ class BorderApp(App):
}
#static1 {
background: red 20%;
color: red;
border: solid red;
}
#static2 {
background: green 20%;
color: green;
border: dashed green;
}
#static3 {
background: blue 20%;
color: blue;
border: tall blue;
}
"""

View File

@@ -12,10 +12,16 @@ Where the fear has gone there will be nothing. Only I will remain."""
class MarginApp(App):
CSS = """
Screen {
background: white;
color: black;
}
Static {
margin: 4 8;
background: blue 20%;
border: blue wide;
}
"""

View File

@@ -0,0 +1,44 @@
from textual.app import App
from textual.widgets import Static
from textual.layout import Horizontal, Vertical
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""
class OverflowApp(App):
CSS = """
Screen {
background: $background;
color: black;
}
Vertical {
width: 1fr;
}
Static {
margin: 1 2;
background: blue 20%;
border: blue wide;
height: auto;
}
#right {
overflow-y: hidden;
}
"""
def compose(self):
yield Horizontal(
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="left"),
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="right"),
)
app = OverflowApp()

View File

@@ -12,6 +12,11 @@ Where the fear has gone there will be nothing. Only I will remain."""
class PaddingApp(App):
CSS = """
Screen {
background: white;
color: blue;
}
Static {
padding: 4 8;