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:
24
docs/examples/styles/text_justify.css
Normal file
24
docs/examples/styles/text_justify.css
Normal 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;
|
||||
}
|
||||
28
docs/examples/styles/text_justify.py
Normal file
28
docs/examples/styles/text_justify.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
class TextJustify(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
left = Static("[b]Left justified[/]\n" + TEXT, id="one")
|
||||
yield left
|
||||
|
||||
right = Static("[b]Center justified[/]\n" + TEXT, id="two")
|
||||
yield right
|
||||
|
||||
center = Static("[b]Right justified[/]\n" + TEXT, id="three")
|
||||
yield center
|
||||
|
||||
full = Static("[b]Full justified[/]\n" + TEXT, id="four")
|
||||
yield full
|
||||
|
||||
|
||||
app = TextJustify(css_path="text_justify.css")
|
||||
@@ -12,7 +12,7 @@ There are a number of rules to set the colors used in Textual scrollbars. You wo
|
||||
| `scrollbar-background-active` | Scrollbar background when the thumb is being dragged |
|
||||
| `scrollbar-corner-color` | The gap between the horizontal and vertical scrollbars |
|
||||
|
||||
## Example:
|
||||
## Syntax
|
||||
|
||||
```
|
||||
scrollbar-color: <COLOR>;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
The `text-justify` rule justifies text within a widget.
|
||||
|
||||
This property is not the same as the `text-justify` property in browser CSS.
|
||||
|
||||
## Syntax
|
||||
|
||||
```
|
||||
@@ -19,8 +21,7 @@ text-justify: [left|center|right|full];
|
||||
|
||||
## Example
|
||||
|
||||
In this example, we can see, from top to bottom,
|
||||
`left`, `center`, `right`, and `full` justified text respectively.
|
||||
This example shows, from top to bottom: `left`, `center`, `right`, and `full` justified text.
|
||||
|
||||
=== "text_justify.py"
|
||||
|
||||
@@ -38,3 +39,19 @@ In this example, we can see, from top to bottom,
|
||||
|
||||
```{.textual path="docs/examples/styles/text_justify.py"}
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```sass
|
||||
/* Set text in all Widgets to be right justified */
|
||||
Widget {
|
||||
text-justify: right;
|
||||
}
|
||||
```
|
||||
|
||||
## Python
|
||||
|
||||
```python
|
||||
# Set text in the widget to be right justified
|
||||
widget.styles.text_justify = "right"
|
||||
```
|
||||
|
||||
11
mkdocs.yml
11
mkdocs.yml
@@ -6,10 +6,10 @@ nav:
|
||||
- "getting_started.md"
|
||||
- "introduction.md"
|
||||
- Guide:
|
||||
- "guide/devtools.md"
|
||||
- "guide/devtools.md"
|
||||
- "guide/CSS.md"
|
||||
- "guide/events.md"
|
||||
|
||||
|
||||
- "actions.md"
|
||||
- Events:
|
||||
- "events/blur.md"
|
||||
@@ -35,7 +35,7 @@ nav:
|
||||
- "events/resize.md"
|
||||
- "events/screen_resume.md"
|
||||
- "events/screen_suspend.md"
|
||||
- "events/show.md"
|
||||
- "events/show.md"
|
||||
- Styles:
|
||||
- "styles/background.md"
|
||||
- "styles/border.md"
|
||||
@@ -53,9 +53,10 @@ nav:
|
||||
- "styles/outline.md"
|
||||
- "styles/overflow.md"
|
||||
- "styles/padding.md"
|
||||
- "styles/scrollbar.md"
|
||||
- "styles/scrollbar_gutter.md"
|
||||
- "styles/scrollbar_size.md"
|
||||
- "styles/scrollbar.md"
|
||||
- "styles/text_justify.md"
|
||||
- "styles/text_style.md"
|
||||
- "styles/tint.md"
|
||||
- "styles/visibility.md"
|
||||
@@ -81,7 +82,7 @@ markdown_extensions:
|
||||
- admonition
|
||||
- def_list
|
||||
- meta
|
||||
|
||||
|
||||
- toc:
|
||||
permalink: true
|
||||
baselevel: 1
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -619,7 +619,7 @@ class Region(NamedTuple):
|
||||
"""Move the offset of the Region.
|
||||
|
||||
Args:
|
||||
translate (tuple[int, int]): Offset to add to region.
|
||||
offset (tuple[int, int]): Offset to add to region.
|
||||
|
||||
Returns:
|
||||
Region: A new region shifted by (x, y)
|
||||
|
||||
@@ -242,7 +242,7 @@ class MessagePump(metaclass=MessagePumpMeta):
|
||||
name: str | None = None,
|
||||
repeat: int = 0,
|
||||
pause: bool = False,
|
||||
):
|
||||
) -> Timer:
|
||||
"""Call a function at periodic intervals.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -1382,9 +1382,6 @@ class Widget(DOMNode):
|
||||
def render(self) -> RenderableType:
|
||||
"""Get renderable for widget.
|
||||
|
||||
Args:
|
||||
style (Styles): The Styles object for this Widget.
|
||||
|
||||
Returns:
|
||||
RenderableType: Any renderable
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user