mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
moar docs
This commit is contained in:
@@ -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"
|
||||
|
||||
9
docs/examples/styles/README.md
Normal file
9
docs/examples/styles/README.md
Normal 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
|
||||
```
|
||||
@@ -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;
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
44
docs/examples/styles/overflow.py
Normal file
44
docs/examples/styles/overflow.py
Normal 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()
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user