mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Docs for text-justify
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user