rich.measure¶
- class rich.measure.Measurement(minimum, maximum)[source]¶
Stores the minimum and maximum widths (in characters) required to render an object.
- clamp(min_width=None, max_width=None)[source]¶
Clamp a measurement within the specified range.
- Parameters
- Returns
New Measurement object.
- Return type
- classmethod get(console, options, renderable)[source]¶
Get a measurement for a renderable.
- Parameters
console (Console) – Console instance.
options (ConsoleOptions) – Console options.
renderable (RenderableType) – An object that may be rendered with Rich.
- Raises
errors.NotRenderableError – If the object is not renderable.
- Returns
Measurement object containing range of character widths required to render the object.
- Return type
- property maximum¶
Maximum number of cells required to render.
- property minimum¶
Minimum number of cells required to render.
- normalize()[source]¶
Get measurement that ensures that minimum <= maximum and minimum >= 0
- Returns
A normalized measurement.
- Return type
- with_maximum(width)[source]¶
Get a RenderableWith where the widths are <= width.
- Parameters
width (int) – Maximum desired width.
- Returns
New Measurement object.
- Return type
- rich.measure.measure_renderables(console, options, renderables)[source]¶
Get a measurement that would fit a number of renderables.
- Parameters
console (Console) – Console instance.
options (ConsoleOptions) – Console options.
renderables (Iterable[RenderableType]) – One or more renderable objects.
- Returns
- Measurement object containing range of character widths required to
contain all given renderables.
- Return type