Skip to content

AnimatedPanel Reference

Bases: AnimatedGradient

Animated variant of :class:rich_gradient.panel.Panel.

Parameters:

Name Type Description Default
renderable RenderableType

Content of the panel. Strings are parsed as console markup, e.g. "Hello, [b]panel[/b]!".

required
colors Optional[list[ColorType]]

Foreground color stops. Each stop may be a color name (Rich/ANSI names such as "red" keep Rich's meaning; CSS names such as "tomato" also work), a hex string ("#f00", "#ff0000"), an "rgb(255, 0, 0)" string, an (r, g, b) tuple, or a rich.color.Color, e.g. ["#f00", "orange", (0, 128, 255)]. If omitted and rainbow is False, hues colors are taken from the spectrum palette. Defaults to None.

None
bg_colors Optional[list[ColorType]]

Background color stops, in the same formats as colors, e.g. ["#000033", "#330033"]. If omitted, no background gradient is applied. Defaults to None.

None
hues int

Number of colors to take from the spectrum palette when colors is omitted (a run of consecutive hues with a random starting point). Valid values are 2 to 17. Defaults to 5.

5
rainbow bool

Use the full 17-color spectrum palette, ignoring colors and hues. Defaults to False.

False
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
expand bool

Expand the output to the full available width. Defaults to True.

True
justify AlignMethod

Horizontal alignment of the panel: "left", "center", or "right". Defaults to "left".

'left'
vertical_justify VerticalAlignMethod

Vertical alignment of the panel: "top", "middle", or "bottom". Defaults to "middle".

'middle'
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. {"error": "bold red", ("warn", "caution"): "yellow"}; a sequence of (words, style[, case_sensitive]) tuples, e.g. [("error", "bold red"), (("warn", "caution"), "yellow", False)]; or HighlightWords instances, e.g. [HighlightWords(words=("error",), style=Style.parse("bold red"))]. Matching is case-sensitive unless case_sensitive is False. Colors in these styles are shown: they replace the gradient on the matched text. Defaults to None.

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. {r"[0-9]+": "bold cyan"}; a sequence of (pattern, style[, flags]) tuples, e.g. [(r"error|fail", "red", re.IGNORECASE)]; or HighlightRegex instances, e.g. [HighlightRegex(pattern=re.compile(r"[0-9]+"), style=Style.parse("cyan"))]. Title and subtitle rules are appended to these. Colors in these styles are shown: they replace the gradient on the matched text. Defaults to None.

None
border_style StyleType

Style of the border, under the gradient. A style string or rich.style.Style, e.g. "dim italic". A foreground color in this style is replaced by the gradient; a background color is kept unless bg_colors is set. Defaults to "".

''
box Box

Box characters for the border, any rich.box constant, e.g. rich.box.HEAVY or rich.box.DOUBLE. Defaults to rich.box.ROUNDED.

ROUNDED
padding int | tuple[int, int] | tuple[int, int, int, int]

Padding inside the border, CSS-style: 1 (all sides), (top_bottom, left_right), or (top, right, bottom, left), e.g. (1, 2). Defaults to (0, 1).

(0, 1)
width Optional[int]

Fixed width in cells, or None to size automatically. Defaults to None.

None
height Optional[int]

Fixed height in lines, or None to size automatically. Defaults to None.

None
style StyleType

Base style of the panel content. A style string or rich.style.Style, e.g. "dim italic". A foreground color in this style is replaced by the gradient (a background color is kept unless bg_colors is set); with border_only, colors here are shown as in a plain Rich panel. Defaults to "".

''
title Optional[TextType]

Title shown in the top border of the panel: a string (parsed as console markup) or a Text. Defaults to None.

None
title_align AlignMethod

Alignment of the title: "left", "center", or "right". Defaults to "center".

'center'
title_style StyleType

Style layered over the gradient on the title text. A style string or rich.style.Style, e.g. "dim italic". Unlike style, a color here is shown, drawn on top of the gradient. Defaults to "bold".

'bold'
subtitle Optional[TextType]

Subtitle shown in the bottom border of the panel: a string (parsed as console markup) or a Text. Defaults to None.

None
subtitle_align AlignMethod

Alignment of the subtitle: "left", "center", or "right". Defaults to "right".

'right'
subtitle_style StyleType

Style layered over the gradient on the subtitle text. A style string or rich.style.Style, e.g. "dim italic". Unlike style, a color here is shown, drawn on top of the gradient. Defaults to "".

''
safe_box bool

Use box characters that render on legacy Windows terminals. Defaults to False.

False
console Optional[Console]

Console used for rendering and measurement. Defaults to rich.get_console().

None
redirect_stdout bool

Redirect sys.stdout into the Live display so prints appear above it. Defaults to False.

False
redirect_stderr bool

Redirect sys.stderr into the Live display so prints appear above it. Defaults to False.

False
auto_refresh bool

Let Live refresh the display on its own timer. Defaults to True.

True
refresh_per_second float

Live refresh and animation frame rate, in frames per second. Must be positive. Defaults to 20.0.

20.0
transient bool

Clear the output from the terminal when the animation stops. Defaults to False.

False
animate Optional[bool]

Whether to animate. The global config is a kill switch: when config.animation_enabled is False ("animate": false in the config file, or RICH_GRADIENT_ANIMATE=0), nothing animates, even if this is True. False renders a single static frame. None is treated as True. Defaults to True.

True
duration Optional[float]

Seconds after which a running animation stops on its own, e.g. 5.0. Must be positive. None runs until stopped. Defaults to None.

None
text_justify AlignMethod

Alignment of the text inside the panel (string content only, keyword-only): "left", "center", or "right". Defaults to "left".

'left'
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 rich.panel.Panel would, keeping its own colors and background. Defaults to False.

False

Raises:

Type Description
ValueError

If a highlight_regex tuple has fewer than two items, hues < 2, or refresh_per_second/duration is not positive.

Source code in src/rich_gradient/animated_panel.py
class AnimatedPanel(AnimatedGradient):
    """Animated variant of :class:`rich_gradient.panel.Panel`.

    Args:
        renderable (RenderableType): Content of the panel. Strings are parsed as console
            markup, e.g. ``"Hello, [b]panel[/b]!"``.
        colors (Optional[list[ColorType]]): Foreground color stops. Each stop may be a
            color name (Rich/ANSI names such as ``"red"`` keep Rich's meaning; CSS names
            such as ``"tomato"`` also work), a hex string (``"#f00"``, ``"#ff0000"``),
            an ``"rgb(255, 0, 0)"`` string, an ``(r, g, b)`` tuple, or a
            ``rich.color.Color``, e.g. ``["#f00", "orange", (0, 128, 255)]``. If omitted
            and ``rainbow`` is False, ``hues`` colors are taken from the spectrum
            palette. Defaults to None.
        bg_colors (Optional[list[ColorType]]): Background color stops, in the same
            formats as ``colors``, e.g. ``["#000033", "#330033"]``. If omitted, no
            background gradient is applied. Defaults to None.
        hues (int): Number of colors to take from the spectrum palette when ``colors``
            is omitted (a run of consecutive hues with a random starting point). Valid
            values are 2 to 17. Defaults to 5.
        rainbow (bool): Use the full 17-color spectrum palette, ignoring ``colors`` and
            ``hues``. Defaults to False.
        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.
        expand (bool): Expand the output to the full available width. Defaults to True.
        justify (AlignMethod): Horizontal alignment of the panel: ``"left"``,
            ``"center"``, or ``"right"``. Defaults to ``"left"``.
        vertical_justify (VerticalAlignMethod): Vertical alignment of the panel:
            ``"top"``, ``"middle"``, or ``"bottom"``. Defaults to ``"middle"``.
        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.
            ``{"error": "bold red", ("warn", "caution"): "yellow"}``; a sequence of
            ``(words, style[, case_sensitive])`` tuples, e.g.
            ``[("error", "bold red"), (("warn", "caution"), "yellow", False)]``; or
            ``HighlightWords`` instances, e.g.
            ``[HighlightWords(words=("error",), style=Style.parse("bold red"))]``.
            Matching is case-sensitive unless ``case_sensitive`` is False. Colors in
            these styles are shown: they replace the gradient on the matched text.
            Defaults to 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. ``{r"[0-9]+": "bold cyan"}``; a sequence of
            ``(pattern, style[, flags])`` tuples, e.g.
            ``[(r"error|fail", "red", re.IGNORECASE)]``; or ``HighlightRegex``
            instances, e.g.
            ``[HighlightRegex(pattern=re.compile(r"[0-9]+"), style=Style.parse("cyan"))]``.
            Title and subtitle rules are appended to these. Colors in these styles are
            shown: they replace the gradient on the matched text. Defaults to None.
        border_style (StyleType): Style of the border, under the gradient. A style
            string or ``rich.style.Style``, e.g. ``"dim italic"``. A foreground color in
            this style is replaced by the gradient; a background color is kept unless
            ``bg_colors`` is set. Defaults to ``""``.
        box (Box): Box characters for the border, any ``rich.box`` constant, e.g.
            ``rich.box.HEAVY`` or ``rich.box.DOUBLE``. Defaults to ``rich.box.ROUNDED``.
        padding (int | tuple[int, int] | tuple[int, int, int, int]): Padding inside the
            border, CSS-style: ``1`` (all sides), ``(top_bottom, left_right)``, or
            ``(top, right, bottom, left)``, e.g. ``(1, 2)``. Defaults to ``(0, 1)``.
        width (Optional[int]): Fixed width in cells, or ``None`` to size automatically.
            Defaults to None.
        height (Optional[int]): Fixed height in lines, or ``None`` to size
            automatically. Defaults to None.
        style (StyleType): Base style of the panel content. A style string or
            ``rich.style.Style``, e.g. ``"dim italic"``. A foreground color in this
            style is replaced by the gradient (a background color is kept unless
            ``bg_colors`` is set); with ``border_only``, colors here are shown as in a
            plain Rich panel. Defaults to ``""``.
        title (Optional[TextType]): Title shown in the top border of the panel: a string
            (parsed as console markup) or a ``Text``. Defaults to None.
        title_align (AlignMethod): Alignment of the title: ``"left"``, ``"center"``, or
            ``"right"``. Defaults to ``"center"``.
        title_style (StyleType): Style layered over the gradient on the title text. A
            style string or ``rich.style.Style``, e.g. ``"dim italic"``. Unlike
            ``style``, a color here is shown, drawn on top of the gradient. Defaults to
            ``"bold"``.
        subtitle (Optional[TextType]): Subtitle shown in the bottom border of the panel:
            a string (parsed as console markup) or a ``Text``. Defaults to None.
        subtitle_align (AlignMethod): Alignment of the subtitle: ``"left"``,
            ``"center"``, or ``"right"``. Defaults to ``"right"``.
        subtitle_style (StyleType): Style layered over the gradient on the subtitle
            text. A style string or ``rich.style.Style``, e.g. ``"dim italic"``. Unlike
            ``style``, a color here is shown, drawn on top of the gradient. Defaults to
            ``""``.
        safe_box (bool): Use box characters that render on legacy Windows terminals.
            Defaults to False.
        console (Optional[Console]): Console used for rendering and measurement.
            Defaults to ``rich.get_console()``.
        redirect_stdout (bool): Redirect ``sys.stdout`` into the Live display so prints
            appear above it. Defaults to False.
        redirect_stderr (bool): Redirect ``sys.stderr`` into the Live display so prints
            appear above it. Defaults to False.
        auto_refresh (bool): Let ``Live`` refresh the display on its own timer. Defaults
            to True.
        refresh_per_second (float): Live refresh and animation frame rate, in frames per
            second. Must be positive. Defaults to 20.0.
        transient (bool): Clear the output from the terminal when the animation stops.
            Defaults to False.
        animate (Optional[bool]): Whether to animate. The global config is a kill
            switch: when ``config.animation_enabled`` is False (``"animate": false`` in
            the config file, or ``RICH_GRADIENT_ANIMATE=0``), nothing animates, even if
            this is True. ``False`` renders a single static frame. ``None`` is treated
            as True. Defaults to True.
        duration (Optional[float]): Seconds after which a running animation stops on its
            own, e.g. ``5.0``. Must be positive. ``None`` runs until stopped. Defaults
            to None.
        text_justify (AlignMethod): Alignment of the text inside the panel (string
            content only, keyword-only): ``"left"``, ``"center"``, or ``"right"``.
            Defaults to ``"left"``.
        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 ``rich.panel.Panel`` would, keeping its own colors and
            background. Defaults to False.

    Raises:
        ValueError: If a ``highlight_regex`` tuple has fewer than two items, ``hues``
            < 2, or ``refresh_per_second``/``duration`` is not positive.
    """

    def __init__(
        self,
        renderable: RenderableType,
        colors: list[ColorType] | None = None,
        bg_colors: list[ColorType] | None = None,
        hues: int = 5,
        rainbow: bool = False,
        repeat_scale: float = 4.0,
        # layout args
        expand: bool = True,
        justify: AlignMethod = "left",
        vertical_justify: VerticalAlignMethod = "middle",
        highlight_words: HighlightWordsType | None = None,
        highlight_regex: HighlightRegexType | None = None,
        border_style: StyleType = "",
        box: Box = ROUNDED,
        padding: int | tuple[int, int] | tuple[int, int, int, int] = (0, 1),
        width: int | None = None,
        height: int | None = None,
        style: StyleType = "",
        title: Text | RichText | TextType | None = None,
        title_align: AlignMethod = "center",
        title_style: StyleType = "bold",
        subtitle: Text | RichText | TextType | None = None,
        subtitle_align: AlignMethod = "right",
        subtitle_style: StyleType = "",
        safe_box: bool = False,
        # live args
        console: Console | None = None,
        redirect_stdout: bool = False,
        redirect_stderr: bool = False,
        auto_refresh: bool = True,
        refresh_per_second: float = 20.0,
        transient: bool = False,
        animate: bool | None = True,
        duration: float | None = None,
        *,
        text_justify: AlignMethod = "left",
        border_only: bool = False,
    ) -> None:
        """Initialize the animated panel; see the class docstring for arguments.

        Raises:
            ValueError: If a ``highlight_regex`` tuple has fewer than two items,
                ``hues`` < 2, or ``refresh_per_second``/``duration`` is not positive.
        """
        panel = _ExpandingRichPanel(
            _normalize_panel_renderable(
                renderable,
                style=style,
                text_justify=text_justify,
                resolve_rich=False,
            ),
            title=title,
            title_align=title_align,
            subtitle=subtitle,
            subtitle_align=subtitle_align,
            border_style=border_style,
            box=box,
            padding=padding,
            expand=expand,
            style=style,
            width=width,
            height=height,
            safe_box=safe_box,
        )

        # Track underlying panel so expand setter on Gradient can propagate
        # changes to the Rich Panel instance.
        self._panel: _ExpandingRichPanel = panel
        self.border_only = border_only

        highlight_list = self._combine_highlight_regex(
            highlight_regex, title, title_style, subtitle, subtitle_style, box
        )

        super().__init__(
            renderables=panel,
            colors=colors,
            bg_colors=bg_colors,
            auto_refresh=auto_refresh,
            refresh_per_second=refresh_per_second,
            console=console,
            transient=transient,
            redirect_stdout=redirect_stdout,
            redirect_stderr=redirect_stderr,
            expand=expand,
            justify=justify,
            vertical_justify=vertical_justify,
            hues=hues,
            rainbow=rainbow,
            repeat_scale=repeat_scale,
            highlight_words=highlight_words,
            highlight_regex=highlight_list,
            animate=animate,
            duration=duration,
        )

    def __rich_measure__(
        self, console: Console, options: ConsoleOptions
    ) -> Measurement:
        """Measure like a plain Rich ``Panel`` so parent layouts share width fairly.

        Args:
            console: The console used for measurement.
            options: The console options for the current render.

        Returns:
            The natural (non-expanded) width range of the panel.
        """
        return self._panel.natural_measure(console, options)

    @property
    def panel(self) -> RichPanel:
        """The underlying Rich panel renderable."""
        return self._panel

    @property
    def border_only(self) -> bool:
        """Whether only the border (with its title and subtitle) takes the gradient."""
        return self._panel.mark_border

    @border_only.setter
    def border_only(self, value: bool) -> None:
        """Paint only the border with the gradient, or the whole panel.

        Args:
            value: ``True`` to leave the content as a plain Rich panel draws it.
        """
        self._panel.mark_border = bool(value)

    def _merge_styles(self, original: Style, gradient_style: Style) -> Style:
        """Merge the gradient into every cell, or only the border when ``border_only``.

        Args:
            original: The segment's style as Rich rendered it.
            gradient_style: The gradient color for the segment's position.

        Returns:
            The merged style; with ``border_only``, content cells keep ``original``.
        """
        if self.border_only:
            return _merge_border_only(original, gradient_style, super()._merge_styles)
        return super()._merge_styles(original, gradient_style)

    @staticmethod
    def _combine_highlight_regex(
        highlight_regex: HighlightRegexType | None,
        title: RenderableType | None,
        title_style: StyleType,
        subtitle: RenderableType | None,
        subtitle_style: StyleType,
        box: Box,
    ) -> Sequence[_RegexHighlight]:
        """Merge user-provided regex highlights with title/subtitle highlights.

        Args:
            highlight_regex: User-supplied regex highlight rules, if any.
            title: The panel title; when truthy, a title-row rule is added.
            title_style: Style for the title-row rule (falls back to "bold").
            subtitle: The panel subtitle; when truthy, a subtitle-row rule is added.
            subtitle_style: Style for the subtitle-row rule.
            box: The panel's box, used to build the border-row patterns.

        Returns:
            A list of ``(pattern, style, flags)`` tuples.

        Raises:
            ValueError: If a sequence entry has fewer than two items.
        """

        def normalize_style(value: object) -> str | Style:
            """Keep ``Style`` objects as-is and stringify anything else.

            Args:
                value: A style or style-like value.

            Returns:
                The ``Style`` unchanged, or ``str(value)``.
            """
            return value if isinstance(value, Style) else str(value)

        if highlight_regex is None:
            highlight_list: list[_RegexHighlight] = []
        elif isinstance(highlight_regex, Mapping):
            highlight_list = [
                (pattern, normalize_style(style), 0)
                for pattern, style in highlight_regex.items()
            ]
        else:
            highlight_list = []
            for entry in highlight_regex:
                if len(entry) < 2:
                    raise ValueError(
                        "Highlight regex tuples must be (pattern, style[, flags])."
                    )
                pattern = entry[0]
                style = entry[1]
                flags = entry[2] if len(entry) > 2 else 0
                highlight_list.append((pattern, normalize_style(style), int(flags)))

        if title:
            title_regex = AnimatedPanel._get_title_regex(box)
            logger.debug("AnimatedPanel title regex: %s", title_regex)
            highlight_list.append(
                (title_regex, normalize_style(title_style or "bold"), 0)
            )
        if subtitle:
            subtitle_regex = AnimatedPanel._get_subtitle_regex(box)
            logger.debug("AnimatedPanel subtitle regex: %s", subtitle_regex)
            highlight_list.append((subtitle_regex, normalize_style(subtitle_style), 0))
        return highlight_list

    @staticmethod
    def _get_title_regex(box: Box) -> str:
        """Generate the regex used to highlight the title row.

        Args:
            box: The panel's box characters.

        Returns:
            A pattern capturing the title text in the top border.
        """
        top_left = escape(box.top_left)
        top = escape(box.top)
        top_right = escape(box.top_right)
        return rf"{top_left}{top}+ (.*?) {top}+{top_right}"

    @staticmethod
    def _get_subtitle_regex(box: Box) -> str:
        """Generate the regex used to highlight the subtitle row.

        Args:
            box: The panel's box characters.

        Returns:
            A pattern capturing the subtitle text in the bottom border.
        """
        bottom_left = escape(box.bottom_left)
        bottom = escape(box.bottom)
        bottom_right = escape(box.bottom_right)
        return rf"{bottom_left}{bottom}+ (.*?) {bottom}+{bottom_right}"

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, hues=5, rainbow=False, repeat_scale=4.0, expand=True, justify='left', vertical_justify='middle', highlight_words=None, highlight_regex=None, border_style='', box=ROUNDED, padding=(0, 1), width=None, height=None, style='', title=None, title_align='center', title_style='bold', subtitle=None, subtitle_align='right', subtitle_style='', safe_box=False, console=None, redirect_stdout=False, redirect_stderr=False, auto_refresh=True, refresh_per_second=20.0, transient=False, animate=True, duration=None, *, text_justify='left', border_only=False)

Initialize the animated panel; see the class docstring for arguments.

Raises:

Type Description
ValueError

If a highlight_regex tuple has fewer than two items, hues < 2, or refresh_per_second/duration is not positive.

Source code in src/rich_gradient/animated_panel.py
def __init__(
    self,
    renderable: RenderableType,
    colors: list[ColorType] | None = None,
    bg_colors: list[ColorType] | None = None,
    hues: int = 5,
    rainbow: bool = False,
    repeat_scale: float = 4.0,
    # layout args
    expand: bool = True,
    justify: AlignMethod = "left",
    vertical_justify: VerticalAlignMethod = "middle",
    highlight_words: HighlightWordsType | None = None,
    highlight_regex: HighlightRegexType | None = None,
    border_style: StyleType = "",
    box: Box = ROUNDED,
    padding: int | tuple[int, int] | tuple[int, int, int, int] = (0, 1),
    width: int | None = None,
    height: int | None = None,
    style: StyleType = "",
    title: Text | RichText | TextType | None = None,
    title_align: AlignMethod = "center",
    title_style: StyleType = "bold",
    subtitle: Text | RichText | TextType | None = None,
    subtitle_align: AlignMethod = "right",
    subtitle_style: StyleType = "",
    safe_box: bool = False,
    # live args
    console: Console | None = None,
    redirect_stdout: bool = False,
    redirect_stderr: bool = False,
    auto_refresh: bool = True,
    refresh_per_second: float = 20.0,
    transient: bool = False,
    animate: bool | None = True,
    duration: float | None = None,
    *,
    text_justify: AlignMethod = "left",
    border_only: bool = False,
) -> None:
    """Initialize the animated panel; see the class docstring for arguments.

    Raises:
        ValueError: If a ``highlight_regex`` tuple has fewer than two items,
            ``hues`` < 2, or ``refresh_per_second``/``duration`` is not positive.
    """
    panel = _ExpandingRichPanel(
        _normalize_panel_renderable(
            renderable,
            style=style,
            text_justify=text_justify,
            resolve_rich=False,
        ),
        title=title,
        title_align=title_align,
        subtitle=subtitle,
        subtitle_align=subtitle_align,
        border_style=border_style,
        box=box,
        padding=padding,
        expand=expand,
        style=style,
        width=width,
        height=height,
        safe_box=safe_box,
    )

    # Track underlying panel so expand setter on Gradient can propagate
    # changes to the Rich Panel instance.
    self._panel: _ExpandingRichPanel = panel
    self.border_only = border_only

    highlight_list = self._combine_highlight_regex(
        highlight_regex, title, title_style, subtitle, subtitle_style, box
    )

    super().__init__(
        renderables=panel,
        colors=colors,
        bg_colors=bg_colors,
        auto_refresh=auto_refresh,
        refresh_per_second=refresh_per_second,
        console=console,
        transient=transient,
        redirect_stdout=redirect_stdout,
        redirect_stderr=redirect_stderr,
        expand=expand,
        justify=justify,
        vertical_justify=vertical_justify,
        hues=hues,
        rainbow=rainbow,
        repeat_scale=repeat_scale,
        highlight_words=highlight_words,
        highlight_regex=highlight_list,
        animate=animate,
        duration=duration,
    )

__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.

Source code in src/rich_gradient/animated_panel.py
def __rich_measure__(
    self, console: Console, options: ConsoleOptions
) -> Measurement:
    """Measure like a plain Rich ``Panel`` so parent layouts share width fairly.

    Args:
        console: The console used for measurement.
        options: The console options for the current render.

    Returns:
        The natural (non-expanded) width range of the panel.
    """
    return self._panel.natural_measure(console, options)