Panel Reference¶
Bases: Gradient
A Rich Panel whose border, title, and content share one gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
renderable
|
RenderableType
|
Content of the panel. Strings are parsed as console
markup, e.g. |
required |
colors
|
Optional[list[ColorType]]
|
Foreground color stops. Each stop may be a
color name (Rich/ANSI names such as |
None
|
bg_colors
|
Optional[list[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
|
title
|
Optional[TextType]
|
Title shown in the top border of the panel: a string
(parsed as console markup) or a |
None
|
title_align
|
AlignMethod
|
Alignment of the title: |
'center'
|
title_style
|
StyleType
|
Style layered over the gradient on the title text. A
style string or |
'bold'
|
subtitle
|
Optional[TextType]
|
Subtitle shown in the bottom border of the panel:
a string (parsed as console markup) or a |
None
|
subtitle_align
|
AlignMethod
|
Alignment of the subtitle: |
'right'
|
subtitle_style
|
StyleType
|
Style layered over the gradient on the subtitle
text. A style string or |
''
|
border_style
|
StyleType
|
Style of the border, under the gradient. A style
string or |
''
|
justify
|
AlignMethod
|
Horizontal alignment of the panel: |
'left'
|
vertical_justify
|
VerticalAlignMethod
|
Vertical alignment of the panel:
|
'middle'
|
box
|
Box
|
Box characters for the border, any |
ROUNDED
|
padding
|
int | tuple[int, int] | tuple[int, int, int, int]
|
Padding inside the
border, CSS-style: |
(0, 1, 0, 1)
|
expand
|
bool
|
Expand the output to the full available width. Defaults to True. |
True
|
text_justify
|
AlignMethod
|
Alignment of the text inside the panel (string
content only): |
'left'
|
style
|
StyleType
|
Base style of the panel content. A style string or
|
''
|
width
|
Optional[int]
|
Fixed width in cells, or |
None
|
height
|
Optional[int]
|
Fixed height in lines, or |
None
|
safe_box
|
bool
|
Use box characters that render on legacy Windows terminals. Defaults to False. |
False
|
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
|
animate
|
bool
|
Mark the content as changing between renders, so highlight
matches are recomputed every frame instead of cached. Static renderables
never animate on their own; use the |
False
|
border_only
|
bool
|
Paint only the border with the gradient (its title and
subtitle too, as Rich draws them in the border style) and draw the content
exactly as a plain |
False
|
Source code in src/rich_gradient/panel.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
border_only
property
writable
¶
Whether only the border (with its title and subtitle) takes the gradient.
panel
property
¶
The underlying Rich Panel renderable.
__init__(renderable, colors=None, bg_colors=None, rainbow=False, hues=5, title=None, title_align='center', title_style='bold', subtitle=None, subtitle_align='right', subtitle_style='', border_style='', justify='left', vertical_justify='middle', box=ROUNDED, padding=(0, 1, 0, 1), expand=True, text_justify='left', style='', width=None, height=None, safe_box=False, highlight_words=None, highlight_regex=None, *, animate=False, border_only=False)
¶
Initialize the gradient panel; see the class docstring for arguments.
Source code in src/rich_gradient/panel.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
__rich_measure__(console, options)
¶
Measure like a plain Rich Panel so parent layouts share width fairly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console
|
Console
|
The console used for measurement. |
required |
options
|
ConsoleOptions
|
The console options for the current render. |
required |
Returns:
| Type | Description |
|---|---|
Measurement
|
The natural (non-expanded) width range of the panel. |