AnimatedText Reference¶
Bases: AnimatedGradient
Animated gradient variant for text content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
TextType
|
The text: a string, Rich |
required |
colors
|
Optional[Sequence[ColorType]]
|
Foreground color stops. Each stop may be
a color name (Rich/ANSI names such as |
None
|
bg_colors
|
Optional[Sequence[ColorType]]
|
Background color stops, in the same
formats as |
None
|
rainbow
|
bool
|
Use the full 17-color spectrum palette, ignoring |
False
|
hues
|
int
|
Number of colors to take from the spectrum palette when |
5
|
expand
|
bool
|
Expand the output to the full console width. Defaults to True. |
True
|
justify
|
AlignMethod
|
Horizontal alignment of the content: |
'left'
|
vertical_justify
|
VerticalAlignMethod
|
Vertical alignment of the content:
|
'top'
|
repeat_scale
|
float
|
Width of one full color cycle as a multiple of the rendered width; larger values give a more gradual gradient. Defaults to 4.0. |
4.0
|
highlight_words
|
Optional[HighlightWordsType]
|
Words to restyle on top of the
gradient. Accepts a mapping of a word (or a tuple of words) to a style, e.g.
|
None
|
highlight_regex
|
Optional[HighlightRegexType]
|
Regular expressions whose
matches are restyled on top of the gradient. Accepts a mapping of a pattern
to a style, e.g. |
None
|
text_kwargs
|
Optional[Mapping[str, Any]]
|
Keyword arguments for
|
None
|
markup
|
bool
|
Parse Rich console markup in string input. Defaults to True. |
True
|
auto_refresh
|
bool
|
Let |
True
|
refresh_per_second
|
float
|
Live refresh and animation frame rate, in frames per second. Must be positive. Defaults to 30.0. |
30.0
|
console
|
Console
|
Console to render to. Defaults to a module-level
|
_console
|
transient
|
bool
|
Clear the output from the terminal when the animation stops. Defaults to False. |
False
|
redirect_stdout
|
bool
|
Redirect |
False
|
redirect_stderr
|
bool
|
Redirect |
False
|
animate
|
Optional[bool]
|
Whether to animate. The global config is a kill
switch: when |
True
|
duration
|
Optional[float]
|
Seconds after which a running animation stops on its
own, e.g. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/rich_gradient/animated_text.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
rich_text
property
¶
The underlying Rich Text renderable.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no renderable has been stored yet. |
TypeError
|
If the stored renderable is not a Rich |
__init__(text, *, colors=None, bg_colors=None, rainbow=False, hues=5, expand=True, justify='left', vertical_justify='top', repeat_scale=4.0, highlight_words=None, highlight_regex=None, text_kwargs=None, markup=True, auto_refresh=True, refresh_per_second=30.0, console=_console, transient=False, redirect_stdout=False, redirect_stderr=False, animate=True, duration=None)
¶
Initialize the animated text; see the class docstring for arguments.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/rich_gradient/animated_text.py
update_text(text, *, text_kwargs=None, markup=None)
¶
Replace the Text content safely during animation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
TextSource
|
New content: a string, Rich |
required |
text_kwargs
|
Mapping[str, Any] | None
|
Keyword arguments for |
None
|
markup
|
bool | None
|
Parse console markup in string input. Defaults to None, which reuses the previous setting. |
None
|