Docs for text-justify

This commit is contained in:
Darren Burns
2022-08-26 14:51:27 +01:00
parent 7bfdd11527
commit 3b155216f0
10 changed files with 115 additions and 30 deletions

View File

@@ -1,35 +1,29 @@
from __future__ import annotations
from rich.text import Text
from textual.app import App, ComposeResult
from textual.widgets import Static
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."""
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 TextJustify(App):
def compose(self) -> ComposeResult:
left = Static(Text(TEXT))
left.styles.text_justify = "left"
left = Static("[b]Left justified[/]\n" + TEXT, id="one")
yield left
right = Static(TEXT)
right.styles.text_justify = "right"
right = Static("[b]Center justified[/]\n" + TEXT, id="two")
yield right
center = Static(TEXT)
center.styles.text_justify = "center"
center = Static("[b]Right justified[/]\n" + TEXT, id="three")
yield center
full = Static(TEXT)
full.styles.text_justify = "full"
full = Static("[b]Full justified[/]\n" + TEXT, id="four")
yield full

View File

@@ -0,0 +1,24 @@
#one {
text-justify: left;
background: lightblue;
}
#two {
text-justify: center;
background: indianred;
}
#three {
text-justify: right;
background: palegreen;
}
#four {
text-justify: full;
background: palevioletred;
}
Static {
padding: 1;
}