MCPcopy
hub / github.com/Textualize/rich / Styled

Class Styled

rich/styled.py:11–34  ·  rich/styled.py::Styled

Apply a style to a renderable. Args: renderable (RenderableType): Any renderable. style (StyleType): A style to apply across the entire renderable.

Source from the content-addressed store, hash-verified

9
10
11class Styled:
12 class="st">"""Apply a style to a renderable.
13
14 Args:
15 renderable (RenderableType): Any renderable.
16 style (StyleType): A style to apply across the entire renderable.
17 class="st">"""
18
19 def __init__(self, renderable: class="st">"RenderableType", style: class="st">"StyleType") -> None:
20 self.renderable = renderable
21 self.style = style
22
23 def __rich_console__(
24 self, console: class="st">"Console", options: class="st">"ConsoleOptions"
25 ) -> class="st">"RenderResult":
26 style = console.get_style(self.style)
27 rendered_segments = console.render(self.renderable, options)
28 segments = Segment.apply_style(rendered_segments, style)
29 return segments
30
31 def __rich_measure__(
32 self, console: class="st">"Console", options: class="st">"ConsoleOptions"
33 ) -> Measurement:
34 return Measurement.get(console, options, self.renderable)
35
36
37if __name__ == class="st">"__main__": class="cm"># pragma: no cover

Callers 6

test_styledFunction · 0.90
summaryMethod · 0.90
__rich_console__Method · 0.85
_collect_renderablesMethod · 0.85
logMethod · 0.85
styled.pyFile · 0.85

Calls

no outgoing calls

Tested by 1

test_styledFunction · 0.72