Skip to content

textual.renderables

A collection of Rich renderables which may be returned from a widget's render() method.

Bar

Bar(
    highlight_range=(0, 0),
    highlight_style="magenta",
    background_style="grey37",
    clickable_ranges=None,
    width=None,
    gradient=None,
)

Thin horizontal bar with a portion highlighted.

Parameters:

Name Type Description Default

highlight_range

tuple[float, float]

The range to highlight.

(0, 0)

highlight_style

StyleType

The style of the highlighted range of the bar.

'magenta'

background_style

StyleType

The style of the non-highlighted range(s) of the bar.

'grey37'

width

int | None

The width of the bar, or None to fill available width.

None

Blank

Blank(color='transparent')

Draw solid background color.

Digits

Digits(text, style='')

Renders a 3X3 unicode 'font' for numerical values.

Parameters:

Name Type Description Default

text

str

Text to display.

required

style

StyleType

Style to apply to the digits.

''

get_width classmethod

get_width(text)

Calculate the width without rendering.

Parameters:

Name Type Description Default

text

str

Text which may be displayed in the Digits widget.

required

Returns:

Type Description
int

width of the text (in cells).

LinearGradient

LinearGradient(angle, stops)

Render a linear gradient with a rotation.

Parameters:

Name Type Description Default

angle

float

Angle of rotation in degrees.

required

stops

Sequence[tuple[float, Color | str]]

List of stop consisting of pairs of offset (between 0 and 1) and color.

required

VerticalGradient

VerticalGradient(color1, color2)

Draw a vertical gradient.

Sparkline

Sparkline(
    data,
    *,
    width,
    min_color=from_rgb(0, 255, 0),
    max_color=from_rgb(255, 0, 0),
    summary_function=max
)

Bases: Generic[T]

A sparkline representing a series of data.

Parameters:

Name Type Description Default

data

Sequence[T]

The sequence of data to render.

required

width

int | None

The width of the sparkline/the number of buckets to partition the data into.

required

min_color

Color

The color of values equal to the min value in data.

from_rgb(0, 255, 0)

max_color

Color

The color of values equal to the max value in data.

from_rgb(255, 0, 0)

summary_function

SummaryFunction[T]

Function that will be applied to each bucket.

max