rich API reference
400 public APIs from rich (Textualize/rich) — 126 classes, 51 functions, 223 methods. Signatures extracted by static analysis of the actual source.
Repository: Textualize/rich
| Kind | Count |
|---|---|
| Classes | 126 |
| Functions | 51 |
| Methods | 223 |
API list
func
rich.__main__.make_test_card() -> TableGet a renderable that demonstrates a number of features.
class
rich._inspect.InspectA renderable to inspect any Python Object.
func
rich._inspect.Inspect.safe_getattr(attr_name:str) -> Tuple[Any, Any]Get attribute or any exception.
func
rich._loop.loop_first(values:Iterable[T]) -> Iterable[Tuple[bool, T]]Iterate and generate a tuple with a flag for first value.
func
rich._loop.loop_last(values:Iterable[T]) -> Iterable[Tuple[bool, T]]Iterate and generate a tuple with a flag for last value.
func
rich._pick.pick_bool(*values:Optional[bool]) -> boolPick the first non-none bool or return the last value.
class
rich._ratio.EdgeAny object that defines an edge (such as Layout).
func
rich._ratio.ratio_distribute(total:int, ratios:List[int], minimums:Optional[List[int]]=None) -> List[int]Distribute an integer total in to parts based on ratios.
func
rich._ratio.ratio_reduce(total:int, ratios:List[int], maximums:List[int], values:List[int]) -> List[int]Divide an integer total in to parts based on ratios.
class
rich._stack.StackA small shim over builtin list.
method
rich._stack.Stack.push(item:T) -> NonePush an item on to the stack (append in stack nomenclature).
method
rich._stack.Stack.top() -> TGet top of stack.
func
rich._timer.timer(subject:str='time') -> Generator[None, None, None]print the elapsed time.
func
rich._unicode_data.load(unicode_version:str='auto') -> CellTableLoad a cell table for the given unicode version.
class
rich._windows.WindowsConsoleFeaturesWindows features available.
class
rich.abc.RichRenderableAn abstract base class for Rich renderables.
class
rich.align.AlignAlign a renderable by adding spaces if necessary.
method
rich.align.Align.center(renderable:'RenderableType', style:Optional[StyleType]=None, *vertical:Optional[VerticalAlignMethod]=None, *pad:bool=True, *width:Optional[int]=None, *height:Optional[int]=None) -> 'Align'Align a renderable to the center.
method
rich.align.Align.left(renderable:'RenderableType', style:Optional[StyleType]=None, *vertical:Optional[VerticalAlignMethod]=None, *pad:bool=True, *width:Optional[int]=None, *height:Optional[int]=None) -> 'Align'Align a renderable to the left.
method
rich.align.Align.right(renderable:'RenderableType', style:Optional[StyleType]=None, *vertical:Optional[VerticalAlignMethod]=None, *pad:bool=True, *width:Optional[int]=None, *height:Optional[int]=None) -> 'Align'Align a renderable to the right.
class
rich.align.VerticalCenterVertically aligns a renderable.
class
rich.ansi.AnsiDecoderTranslate ANSI code in to styled Text.
method
rich.ansi.AnsiDecoder.decode(terminal_text:str) -> Iterable[Text]Decode ANSI codes in an iterable of lines.
method
rich.ansi.AnsiDecoder.decode_line(line:str) -> TextDecode a line containing ansi codes.
class
rich.bar.BarRenders a solid block bar.
class
rich.box.BoxDefines characters to render boxes.
method
rich.box.Box.get_bottom(widths:Iterable[int]) -> strGet the bottom of a simple box.
method
rich.box.Box.get_row(widths:Iterable[int], level:Literal['head', 'row', 'foot', 'mid']='row', edge:bool=True) -> strGet the top of a simple box.
method
rich.box.Box.get_top(widths:Iterable[int]) -> strGet the top of a simple box.
func
rich.cells.cached_cell_len(text:str, unicode_version:str='auto') -> intGet the number of cells required to display text.
func
rich.cells.cell_len(text:str, unicode_version:str='auto') -> intGet the cell length of a string (length as it appears in the terminal).
func
rich.cells.get_character_cell_size(character:str, unicode_version:str='auto') -> intGet the cell size of a character.
func
rich.cells.split_text(text:str, cell_position:int, unicode_version:str='auto') -> tuple[str, str]Split text by cell position.
class
rich.color.ColorTerminal color definition.
method
rich.color.Color.default() -> 'Color'Get a Color instance representing the default color.
method
rich.color.Color.downgrade(system:ColorSystem) -> 'Color'Downgrade a color system to a system with fewer colors.
method
rich.color.Color.from_ansi(number:int) -> 'Color'Create a Color number from it's 8-bit ansi number.
method
rich.color.Color.from_rgb(red:float, green:float, blue:float) -> 'Color'Create a truecolor from three color components in the range(0->255).
method
rich.color.Color.from_triplet(triplet:'ColorTriplet') -> 'Color'Create a truecolor RGB color from a triplet of values.
method
rich.color.Color.get_ansi_codes(foreground:bool=True) -> Tuple[str, ...]Get the ANSI escape codes for this color.
method
rich.color.Color.get_truecolor(theme:Optional['TerminalTheme']=None, foreground:bool=True) -> ColorTripletGet an equivalent color triplet for this color.
method
rich.color.Color.is_default() -> boolCheck if the color is a default color.
method
rich.color.Color.is_system_defined() -> boolCheck if the color is ultimately defined by the system.
method
rich.color.Color.parse(color:str) -> 'Color'Parse a color definition.
method
rich.color.Color.system() -> ColorSystemGet the native color system for this color.
class
rich.color.ColorParseErrorThe color could not be parsed.
class
rich.color.ColorSystemOne of the 3 color system supported by terminals.
class
rich.color.ColorTypeType of color stored in Color class.
func
rich.color.blend_rgb(color1:ColorTriplet, color2:ColorTriplet, cross_fade:float=0.5) -> ColorTripletBlend one RGB color in to another.
func
rich.color.parse_rgb_hex(hex_color:str) -> ColorTripletParse six hex characters in to RGB triplet.
class
rich.color_triplet.ColorTripletThe red, green, and blue components of a color.
method
rich.color_triplet.ColorTriplet.hex() -> strget the color triplet in CSS style.
method
rich.color_triplet.ColorTriplet.normalized() -> Tuple[float, float, float]Convert components into floats between 0 and 1.
method
rich.color_triplet.ColorTriplet.rgb() -> strThe color in RGB format.
class
rich.columns.ColumnsDisplay renderables in neat columns.
method
rich.columns.Columns.add_renderable(renderable:RenderableType) -> NoneAdd a renderable to the columns.
class
rich.console.CaptureContext manager to capture the result of printing to the console.
method
rich.console.Capture.get() -> strGet the result of the capture.
class
rich.console.CaptureErrorAn error in the Capture context manager.
class
rich.console.ConsoleA high level console interface.
method
rich.console.Console.begin_capture() -> NoneBegin capturing console output.
method
rich.console.Console.bell() -> NonePlay a 'bell' sound (if supported by the terminal).
method
rich.console.Console.clear(home:bool=True) -> NoneClear the screen.
method
rich.console.Console.clear_live() -> NoneClear the Live instance.
method
rich.console.Console.color_system() -> Optional[str]Get color system string.
method
rich.console.Console.control(*control:Control) -> NoneInsert non-printing control codes.
method
rich.console.Console.encoding() -> strGet the encoding of the console file, e.g.
method
rich.console.Console.end_capture() -> strEnd capture mode and return captured string.
func
rich.console.Console.escape_text(text:str) -> strHTML escape text and replace spaces with nbsp.
method
rich.console.Console.file() -> IO[str]Get the file object to write to.
method
rich.console.Console.get_style(name:Union[str, Style], *default:Optional[Union[Style, str]]=None) -> StyleGet a Style instance by its theme name or parse a definition.
func
rich.console.Console.get_svg_style(style:Style) -> strConvert a Style to CSS rules for SVG.
method
rich.console.Console.height() -> intGet the height of the console.
method
rich.console.Console.input(prompt:TextType='', *markup:bool=True, *emoji:bool=True, *password:bool=False, *stream:Optional[TextIO]=None) -> strDisplays a prompt and waits for input from the user.
method
rich.console.Console.is_alt_screen() -> boolCheck if the alt screen was enabled.
method
rich.console.Console.is_dumb_terminal() -> boolDetect dumb terminal.
func
rich.console.Console.is_expandable(obj:object) -> boolCheck if an object is expandable by pretty printer.
method
rich.console.Console.is_terminal() -> boolCheck if the console is writing to a terminal.
method
rich.console.Console.line(count:int=1) -> NoneWrite new line(s).
func
rich.console.Console.make_tag(name:str, content:Optional[str]=None, **attribs:object) -> strMake a tag from name, content, and attributes.
method
rich.console.Console.measure(renderable:RenderableType, *options:Optional[ConsoleOptions]=None) -> MeasurementMeasure a renderable.
method
rich.console.Console.on_broken_pipe() -> NoneThis function is called when a `BrokenPipeError` is raised.
method
rich.console.Console.options() -> ConsoleOptionsGet default console options.
method
rich.console.Console.out(*sep:str=' ', *end:str='\n', *style:Optional[Union[str, Style]]=None, *highlight:Optional[bool]=None, *objects:Any) -> NoneOutput to the terminal.
method
rich.console.Console.pop_render_hook() -> NonePop the last renderhook from the stack.
method
rich.console.Console.pop_theme() -> NoneRemove theme from top of stack, restoring previous theme.
method
rich.console.Console.push_render_hook(hook:RenderHook) -> NoneAdd a new render hook to the stack.
method
rich.console.Console.render(renderable:RenderableType, options:Optional[ConsoleOptions]=None) -> Iterable[Segment]Render an object in to an iterable of `Segment` instances.
method
rich.console.Console.render_lines(renderable:RenderableType, options:Optional[ConsoleOptions]=None, *style:Optional[Style]=None, *pad:bool=True, *new_lines:bool=False) -> List[List[Segment]]Render objects in to a list of lines.
method
rich.console.Console.rule(title:TextType='', *characters:str='─', *style:Union[str, Style]='rule.line', *align:AlignMethod='center') -> NoneDraw a line with optional centered title.
method
rich.console.Console.set_alt_screen(enable:bool=True) -> boolEnables alternative screen mode.
method
rich.console.Console.set_live(live:'Live') -> boolSet Live instance.
method
rich.console.Console.set_window_title(title:str) -> boolSet the title of the console terminal window.
method
rich.console.Console.show_cursor(show:bool=True) -> boolShow or hide the cursor.
method
rich.console.Console.size() -> ConsoleDimensionsGet the size of the console.
method
rich.console.Console.status(status:RenderableType, *spinner:str='dots', *spinner_style:StyleType='status.spinner', *speed:float=1.0, *refresh_per_second:float=12.5) -> 'Status'Display a status and spinner.
method
rich.console.Console.update_screen(renderable:RenderableType, *region:Optional[Region]=None, *options:Optional[ConsoleOptions]=None) -> NoneUpdate the screen at a given offset.
method
rich.console.Console.update_screen_lines(lines:List[List[Segment]], x:int=0, y:int=0) -> NoneUpdate lines of the screen at a given offset.
method
rich.console.Console.use_theme(theme:Theme, *inherit:bool=True) -> ThemeContextUse a different theme for the duration of the context manager.
method
rich.console.Console.width() -> intGet the width of the console.
class
rich.console.ConsoleDimensionsSize of the terminal.
class
rich.console.ConsoleOptionsOptions for __rich_console__ method.
method
rich.console.ConsoleOptions.ascii_only() -> boolCheck if renderables should use ascii only.
method
rich.console.ConsoleOptions.copy() -> 'ConsoleOptions'Return a copy of the options.
method
rich.console.ConsoleOptions.reset_height() -> 'ConsoleOptions'Return a copy of the options with height set to ``None``.
method
rich.console.ConsoleOptions.update_dimensions(width:int, height:int) -> 'ConsoleOptions'Update the width and height, and return a copy.
method
rich.console.ConsoleOptions.update_height(height:int) -> 'ConsoleOptions'Update the height, and return a copy.
method
rich.console.ConsoleOptions.update_width(width:int) -> 'ConsoleOptions'Update just the width, return a copy.
class
rich.console.ConsoleRenderableAn object that supports the console protocol.
class
rich.console.ConsoleThreadLocalsThread local values for Console context.
class
rich.console.NewLineA renderable to generate new line(s)
class
rich.console.PagerContextA context manager that 'pages' content.
class
rich.console.RenderHookProvides hooks in to the render process.
method
rich.console.RenderHook.process_renderables(renderables:List[ConsoleRenderable]) -> List[ConsoleRenderable]Called with a list of objects to render.
class
rich.console.RichCastAn object that may be 'cast' to a console renderable.
class
rich.console.ScreenContextA context manager that enables an alternative screen.
method
rich.console.ScreenContext.update(*style:Optional[StyleType]=None, *renderables:RenderableType) -> NoneUpdate the screen.
class
rich.console.ScreenUpdateRender a list of lines at a given offset.
class
rich.console.ThemeContextA context manager to use a temporary theme.
func
rich.console.detect_legacy_windows() -> boolDetect legacy Windows.
func
rich.console.group(fit:bool=True) -> Callable[..., Callable[..., Group]]A decorator that turns an iterable of renderables in to a group.
class
rich.containers.LinesA list subclass which can render to the console.
method
rich.containers.Lines.justify(console:'Console', width:int, justify:'JustifyMethod'='left', overflow:'OverflowMethod'='fold') -> NoneJustify and overflow text to a given width.
class
rich.containers.RenderablesA list subclass which renders its contents to the console.
method
rich.control.Control.alt_screen(enable:bool) -> 'Control'Enable or disable alt screen.
method
rich.control.Control.bell() -> 'Control'Ring the 'bell'.
method
rich.control.Control.clear() -> 'Control'Clear the screen.
method
rich.control.Control.home() -> 'Control'Move cursor to 'home' position.
method
rich.control.Control.move(x:int=0, y:int=0) -> 'Control'Move cursor relative to current position.
method
rich.control.Control.move_to(x:int, y:int) -> 'Control'Move cursor to absolute position.
method
rich.control.Control.move_to_column(x:int, y:int=0) -> 'Control'Move to the given column, optionally add offset to row.
method
rich.control.Control.show_cursor(show:bool) -> 'Control'Show or hide the cursor.
func
rich.control.strip_control_codes(text:str, _translate_table:Dict[int, None]=_CONTROL_STRIP_TRANSLATE) -> strRemove control codes from text.
func
rich.diagnose.report() -> NonePrint a report to the terminal with debugging information
class
rich.emoji.NoEmojiNo emoji by that name.
class
rich.errors.ConsoleErrorAn error in console operation.
class
rich.errors.LiveErrorError related to Live display.
class
rich.errors.MarkupErrorMarkup was badly formatted.
class
rich.errors.MissingStyleNo such style.
class
rich.errors.NoAltScreenAlt screen mode was required.
class
rich.errors.NotRenderableErrorObject is not renderable.
class
rich.errors.StyleErrorAn error in styles.
class
rich.errors.StyleStackErrorStyle stack is invalid.
class
rich.errors.StyleSyntaxErrorStyle was badly formatted.
class
rich.file_proxy.FileProxyWraps a file (e.g.
method
rich.file_proxy.FileProxy.rich_proxied_file() -> IO[str]Get proxied file.
func
rich.filesize.decimal(size:int, *precision:Optional[int]=1, *separator:Optional[str]=' ') -> strConvert a filesize in to a string (powers of 1000, SI prefixes).
func
rich.filesize.pick_unit_and_suffix(size:int, suffixes:List[str], base:int) -> Tuple[int, str]Pick a suffix and base for the given size.
func
rich.get_console() -> 'Console'Get a global :class:`~rich.console.Console` instance.
class
rich.highlighter.HighlighterAbstract base class for highlighters.
method
rich.highlighter.Highlighter.highlight(text:Text) -> NoneApply highlighting in place to text.
class
rich.highlighter.ISO8601HighlighterHighlights the ISO8601 date time strings.
class
rich.highlighter.JSONHighlighterHighlights JSON
class
rich.highlighter.NullHighlighterA highlighter object that doesn't highlight.
method
rich.highlighter.NullHighlighter.highlight(text:Text) -> NoneNothing to do
class
rich.highlighter.RegexHighlighterApplies highlighting from a list of regular expressions.
method
rich.highlighter.RegexHighlighter.highlight(text:Text) -> NoneHighlight :class:`rich.text.Text` using regular expressions.
func
rich.inspect(obj:Any, *console:Optional['Console']=None, *title:Optional[str]=None, *help:bool=False, *methods:bool=False, *docs:bool=True, *private:bool=False, *dunder:bool=False, *sort:bool=True, *all:bool=False, *value:bool=True) -> NoneInspect any Python object.
class
rich.json.JSONA renderable which pretty prints JSON.
class
rich.jupyter.JupyterMixinAdd to an Rich renderable to make it render in Jupyter notebook.
class
rich.jupyter.JupyterRenderableA shim to write html to Jupyter notebook.
func
rich.jupyter.display(segments:Iterable[Segment], text:str) -> NoneRender segments to Jupyter.
func
rich.jupyter.escape(text:str) -> strEscape html.
func
rich.jupyter.print(*args:Any, **kwargs:Any) -> NoneProxy for Console print.
class
rich.layout.ColumnSplitterSplit a layout region in to columns.
class
rich.layout.LayoutA renderable to divide a fixed height in to rows or columns.
method
rich.layout.Layout.add_split(*layouts:Union['Layout', RenderableType]) -> NoneAdd a new layout(s) to existing split.
method
rich.layout.Layout.children() -> List['Layout']Gets (visible) layout children.
method
rich.layout.Layout.get(name:str) -> Optional['Layout']Get a named layout, or None if it doesn't exist.
method
rich.layout.Layout.map() -> RenderMapGet a map of the last render.
method
rich.layout.Layout.refresh_screen(console:'Console', layout_name:str) -> NoneRefresh a sub-layout.
method
rich.layout.Layout.render(console:Console, options:ConsoleOptions) -> RenderMapRender the sub_layouts.
method
rich.layout.Layout.renderable() -> RenderableTypeLayout renderable.
method
rich.layout.Layout.split(*splitter:Union[Splitter, str]='column', *layouts:Union['Layout', RenderableType]) -> NoneSplit the layout in to multiple sub-layouts.
method
rich.layout.Layout.split_row(*layouts:Union['Layout', RenderableType]) -> NoneSplit the layout in to a row (layouts side by side).
method
rich.layout.Layout.tree() -> 'Tree'Get a tree renderable to show layout structure.
method
rich.layout.Layout.unsplit() -> NoneReset splits to initial state.
method
rich.layout.Layout.update(renderable:RenderableType) -> NoneUpdate renderable.
class
rich.layout.LayoutErrorLayout related error.
class
rich.layout.LayoutRenderAn individual layout render.
class
rich.layout.NoSplitterRequested splitter does not exist.
class
rich.layout.RowSplitterSplit a layout region in to rows.
class
rich.layout.SplitterBase class for a splitter.
method
rich.layout.Splitter.divide(children:Sequence['Layout'], region:Region) -> Iterable[Tuple['Layout', Region]]Divide a region amongst several child layouts.
method
rich.layout.Splitter.get_tree_icon() -> strGet the icon (emoji) used in layout.tree
class
rich.live.LiveRenders an auto-updating live display of any given renderable.
method
rich.live.Live.is_started() -> boolCheck if live display has been started.
method
rich.live.Live.process_renderables(renderables:List[ConsoleRenderable]) -> List[ConsoleRenderable]Process renderables to restore cursor and display progress.
method
rich.live.Live.refresh() -> NoneUpdate the display of the Live Render.
method
rich.live.Live.start(refresh:bool=False) -> NoneStart live rendering display.
method
rich.live.Live.stop() -> NoneStop live rendering display.
class
rich.live_render.LiveRenderCreates a renderable that may be updated.
method
rich.live_render.LiveRender.set_renderable(renderable:RenderableType) -> NoneSet a new renderable.
class
rich.logging.RichHandlerA logging handler that renders output with Rich.
method
rich.logging.RichHandler.emit(record:LogRecord) -> NoneInvoked by logging.
method
rich.logging.RichHandler.get_level_text(record:LogRecord) -> TextGet the level name from the record.
method
rich.logging.RichHandler.render(*record:LogRecord, *traceback:Optional[Traceback], *message_renderable:ConsoleRenderable) -> ConsoleRenderableRender log for display.
method
rich.logging.RichHandler.render_message(record:LogRecord, message:str) -> ConsoleRenderableRender message text in to Text.
class
rich.markdown.BlockQuoteA block quote.
class
rich.markdown.CodeBlockA code block with syntax highlighting.
class
rich.markdown.HeadingA heading.
class
rich.markdown.HorizontalRuleA horizontal rule to divide sections.
class
rich.markdown.ImageItemRenders a placeholder for an image.
class
rich.markdown.ListElementA list element.
class
rich.markdown.ListItemAn item in a list.
class
rich.markdown.MarkdownA Markdown renderable.
class
rich.markdown.MarkdownContextManages the console render state.
method
rich.markdown.MarkdownContext.enter_style(style_name:str | Style) -> StyleEnter a style context.
method
rich.markdown.MarkdownContext.leave_style() -> StyleLeave a style context.
method
rich.markdown.MarkdownContext.on_text(text:str, node_type:str) -> NoneCalled when the parser visits text.
class
rich.markdown.ParagraphA Paragraph.
class
rich.markdown.TableElementMarkdownElement corresponding to `table_open`.
class
rich.markdown.TableRowElementMarkdownElement corresponding to `tr_open` and `tr_close`.
class
rich.markdown.TextElementBase class for elements that render text.
class
rich.markdown.UnknownElementAn unknown element.
class
rich.markup.TagA tag in console markup.
method
rich.markup.Tag.markup() -> strGet the string representation of this tag.
func
rich.markup.escape(markup:str, _escape:_EscapeSubMethod=re.compile('(\\\\*)(\\[[a-z#/@][^[]*?])').sub) -> strEscapes text so that it won't be interpreted as markup.
func
rich.markup.escape_backslashes(match:Match[str]) -> strCalled by re.sub replace matches.
func
rich.markup.pop_style(style_name:str) -> Tuple[int, Tag]Pop tag matching given style name.
func
rich.markup.render(markup:str, style:Union[str, Style]='', emoji:bool=True, emoji_variant:Optional[EmojiVariant]=None) -> TextRender console markup in to a Text instance.
method
rich.measure.Measurement.clamp(min_width:Optional[int]=None, max_width:Optional[int]=None) -> 'Measurement'Clamp a measurement within the specified range.
method
rich.measure.Measurement.get(console:'Console', options:'ConsoleOptions', renderable:'RenderableType') -> 'Measurement'Get a measurement for a renderable.
method
rich.measure.Measurement.span() -> intGet difference between maximum and minimum.
method
rich.measure.Measurement.with_maximum(width:int) -> 'Measurement'Get a RenderableWith where the widths are <= width.
method
rich.measure.Measurement.with_minimum(width:int) -> 'Measurement'Get a RenderableWith where the widths are >= width.
class
rich.padding.PaddingDraw space around content.
method
rich.padding.Padding.indent(renderable:'RenderableType', level:int) -> 'Padding'Make padding instance to render an indent.
method
rich.padding.Padding.unpack(pad:'PaddingDimensions') -> Tuple[int, int, int, int]Unpack padding specified in CSS style.
class
rich.pager.PagerBase class for a pager.
method
rich.pager.Pager.show(content:str) -> NoneShow content in pager.
class
rich.pager.SystemPagerUses the pager installed on the system.
method
rich.pager.SystemPager.show(content:str) -> NoneUse the same pager used by pydoc.
class
rich.palette.PaletteA palette of available colors.
func
rich.palette.Palette.get_color_distance(index:int) -> floatGet the distance to a color.
method
rich.palette.Palette.match(color:Tuple[int, int, int]) -> intFind a color from a palette that most closely matches a given color.
class
rich.panel.PanelA console renderable that draws a border around its contents.
func
rich.panel.Panel.align_text(text:Text, width:int, align:str, character:str, style:Style) -> TextGets new aligned text.
class
rich.pretty.NodeA node in a repr tree.
method
rich.pretty.Node.check_length(start_length:int, max_length:int) -> boolCheck the length fits within a limit.
method
rich.pretty.Node.iter_tokens() -> Iterable[str]Generate tokens for this node.
method
rich.pretty.Node.render(max_width:int=80, indent_size:int=4, expand_all:bool=False) -> strRender the node to a pretty repr.
class
rich.pretty.PrettyA rich renderable that pretty prints an object.
func
rich.pretty.display_hook(value:Any) -> NoneReplacement sys.displayhook which prettifies objects with Rich.
func
rich.pretty.is_expandable(obj:Any) -> boolCheck if an object may be expanded by pretty print.
func
rich.pretty.iter_attrs() -> Iterable[Tuple[str, Any, Optional[Callable[[Any], str]]]]Iterate over attr fields and values.
func
rich.pretty.to_repr(obj:Any) -> strGet repr string for an object, but catch errors.
func
rich.pretty.traverse(_object:Any, max_length:Optional[int]=None, max_string:Optional[int]=None, max_depth:Optional[int]=None) -> NodeTraverse object and generate a tree.
func
rich.print(*sep:str=' ', *end:str='\n', *file:Optional[IO[str]]=None, *flush:bool=False, *objects:Any) -> NonePrint object(s) supplied via positional arguments.
func
rich.print_json(json:Optional[str]=None, *data:Any=None, *indent:Union[None, int, str]=2, *highlight:bool=True, *skip_keys:bool=False, *ensure_ascii:bool=False, *check_circular:bool=True, *allow_nan:bool=True, *default:Optional[Callable[[Any], Any]]=None, *sort_keys:bool=False) -> NonePretty prints JSON.
class
rich.progress.BarColumnRenders a visual progress bar.
method
rich.progress.BarColumn.render(task:'Task') -> ProgressBarGets a progress bar widget for a task.
class
rich.progress.DownloadColumnRenders file size downloaded and total, e.g.
method
rich.progress.DownloadColumn.render(task:'Task') -> TextCalculate common unit for completed and total.
class
rich.progress.FileSizeColumnRenders completed filesize.
method
rich.progress.FileSizeColumn.render(task:'Task') -> TextShow data completed.
class
rich.progress.MofNCompleteColumnRenders completed count/total, e.g.
method
rich.progress.MofNCompleteColumn.render(task:'Task') -> TextShow completed/total.
class
rich.progress.ProgressRenders an auto-updating progress bar(s).
method
rich.progress.Progress.add_task(description:str, start:bool=True, total:Optional[float]=100.0, completed:int=0, visible:bool=True, **fields:Any) -> TaskIDAdd a new 'task' to the Progress display.
method
rich.progress.Progress.advance(task_id:TaskID, advance:float=1) -> NoneAdvance task by a number of steps.
method
rich.progress.Progress.finished() -> boolCheck if all tasks have been completed.
method
rich.progress.Progress.get_renderable() -> RenderableTypeGet a renderable for the progress display.
method
rich.progress.Progress.get_renderables() -> Iterable[RenderableType]Get a number of renderables for the progress display.
method
rich.progress.Progress.make_tasks_table(tasks:Iterable[Task]) -> TableGet a table to render the Progress display.
method
rich.progress.Progress.refresh() -> NoneRefresh (render) the progress information.
method
rich.progress.Progress.remove_task(task_id:TaskID) -> NoneDelete a task if it exists.
method
rich.progress.Progress.start() -> NoneStart the progress display.
method
rich.progress.Progress.start_task(task_id:TaskID) -> NoneStart a task.
method
rich.progress.Progress.stop() -> NoneStop the progress display.
method
rich.progress.Progress.stop_task(task_id:TaskID) -> NoneStop a task.
method
rich.progress.Progress.task_ids() -> List[TaskID]A list of task IDs.
method
rich.progress.Progress.wrap_file(file:BinaryIO, total:Optional[int]=None, *task_id:Optional[TaskID]=None, *description:str='Reading...') -> BinaryIOTrack progress file reading from a binary file.
class
rich.progress.ProgressColumnBase class for a widget to use in progress display.
method
rich.progress.ProgressColumn.get_table_column() -> ColumnGet a table column, used to build tasks table.
method
rich.progress.ProgressColumn.render(task:'Task') -> RenderableTypeShould return a renderable object.
class
rich.progress.ProgressSampleSample of progress for a given time.
class
rich.progress.RenderableColumnA column to insert an arbitrary column.
class
rich.progress.SpinnerColumnA column with a 'spinner' animation.
method
rich.progress.SpinnerColumn.set_spinner(spinner_name:str, spinner_style:Optional[StyleType]='progress.spinner', speed:float=1.0) -> NoneSet a new spinner.
class
rich.progress.TaskInformation regarding a progress task.
method
rich.progress.Task.finished() -> boolCheck if the task has finished.
method
rich.progress.Task.get_time() -> floatfloat: Get the current time, in seconds.
method
rich.progress.Task.percentage() -> floatfloat: Get progress of task as a percentage.
method
rich.progress.Task.started() -> boolbool: Check if the task as started.
class
rich.progress.TaskProgressColumnShow task progress as a percentage.
method
rich.progress.TaskProgressColumn.render_speed(speed:Optional[float]) -> TextRender the speed in iterations per second.
class
rich.progress.TextColumnA column containing text.
class
rich.progress.TimeElapsedColumnRenders time elapsed.
method
rich.progress.TimeElapsedColumn.render(task:'Task') -> TextShow time elapsed.
class
rich.progress.TimeRemainingColumnRenders estimated time remaining.
method
rich.progress.TimeRemainingColumn.render(task:'Task') -> TextShow time remaining.
class
rich.progress.TotalFileSizeColumnRenders total filesize.
method
rich.progress.TotalFileSizeColumn.render(task:'Task') -> TextShow data completed.
class
rich.progress.TransferSpeedColumnRenders human readable transfer speed.
method
rich.progress.TransferSpeedColumn.render(task:'Task') -> TextShow data transfer speed.
class
rich.progress_bar.ProgressBarRenders a (progress) bar.
method
rich.progress_bar.ProgressBar.percentage_completed() -> Optional[float]Calculate percentage complete.
method
rich.progress_bar.ProgressBar.update(completed:float, total:Optional[float]=None) -> NoneUpdate progress with new values.
class
rich.prompt.ConfirmA yes / no confirmation prompt.
method
rich.prompt.Confirm.process_response(value:str) -> boolConvert choices to a bool.
method
rich.prompt.Confirm.render_default(default:DefaultType) -> TextRender the default as (y) or (n) rather than True/False.
class
rich.prompt.FloatPromptA prompt that returns a float.
class
rich.prompt.IntPromptA prompt that returns an integer.
class
rich.prompt.InvalidResponseException to indicate a response was invalid.
class
rich.prompt.PromptA prompt that returns a str.
class
rich.prompt.PromptBaseAsk the user for input until a valid response is received.
method
rich.prompt.PromptBase.check_choice(value:str) -> boolCheck value is in the list of valid choices.
method
rich.prompt.PromptBase.get_input(console:Console, prompt:TextType, password:bool, stream:Optional[TextIO]=None) -> strGet input from user.
method
rich.prompt.PromptBase.make_prompt(default:DefaultType) -> TextMake prompt text.
method
rich.prompt.PromptBase.on_validate_error(value:str, error:InvalidResponse) -> NoneCalled to handle validation error.
method
rich.prompt.PromptBase.pre_prompt() -> NoneHook to display something before the prompt.
method
rich.prompt.PromptBase.process_response(value:str) -> PromptTypeProcess response from user, convert to prompt type.
method
rich.prompt.PromptBase.render_default(default:DefaultType) -> TextTurn the supplied default in to a Text instance.
class
rich.prompt.PromptErrorException base class for prompt related errors.
func
rich.protocol.is_renderable(check_object:Any) -> boolCheck if an object may be rendered by Rich.
func
rich.protocol.rich_cast(renderable:object) -> 'RenderableType'Cast an object to a renderable by calling __rich__ if present.
func
rich.reconfigure(*args:Any, **kwargs:Any) -> NoneReconfigures the global console by replacing it with another.
class
rich.region.RegionDefines a rectangular region of the screen.
class
rich.repr.ReprErrorAn error occurred when attempting to build a repr.
func
rich.repr.auto_repr(self:T) -> strCreate repr string from __rich_repr__
func
rich.repr.auto_rich_repr(self:Type[T]) -> ResultAuto generate __rich_rep__ from signature of __init__
class
rich.rule.RuleA console renderable to draw a horizontal rule (line).
func
rich.scope.sort_items(item:Tuple[str, Any]) -> Tuple[bool, str]Sort special variables first, then alphabetically.
class
rich.screen.ScreenA renderable that fills the terminal screen and crops excess.
class
rich.segment.SegmentA piece of text with associated style.
method
rich.segment.Segment.apply_style(segments:Iterable['Segment'], style:Optional[Style]=None, post_style:Optional[Style]=None) -> Iterable['Segment']Apply style(s) to an iterable of segments.
method
rich.segment.Segment.cell_length() -> intThe number of terminal cells required to display self.text.
method
rich.segment.Segment.divide(segments:Iterable['Segment'], cuts:Iterable[int]) -> Iterable[List['Segment']]Divides an iterable of segments in to portions.
method
rich.segment.Segment.filter_control(segments:Iterable['Segment'], is_control:bool=False) -> Iterable['Segment']Filter segments by ``is_control`` attribute.
method
rich.segment.Segment.get_line_length(line:List['Segment']) -> intGet the length of list of segments.
method
rich.segment.Segment.get_shape(lines:List[List['Segment']]) -> Tuple[int, int]Get the shape (enclosing rectangle) of a list of lines.
method
rich.segment.Segment.is_control() -> boolCheck if the segment contains control codes.
method
rich.segment.Segment.line() -> 'Segment'Make a new line segment.
method
rich.segment.Segment.remove_color(segments:Iterable['Segment']) -> Iterable['Segment']Remove all color from an iterable of segments.
method
rich.segment.Segment.split_cells(cut:int) -> Tuple['Segment', 'Segment']Split segment in to two segments at the specified column.
method
rich.segment.Segment.split_lines(segments:Iterable['Segment']) -> Iterable[List['Segment']]Split a sequence of segments in to a list of lines.
method
rich.segment.Segment.strip_links(segments:Iterable['Segment']) -> Iterable['Segment']Remove all links from an iterable of styles.
method
rich.segment.Segment.strip_styles(segments:Iterable['Segment']) -> Iterable['Segment']Remove all styles from an iterable of segments.
class
rich.segment.SegmentsA simple renderable to render an iterable of segments.
class
rich.spinner.SpinnerA spinner animation.
method
rich.spinner.Spinner.render(time:float) -> 'RenderableType'Render the spinner for a given time.
class
rich.status.StatusDisplays a status indicator with a 'spinner' animation.
method
rich.status.Status.console() -> 'Console'Get the Console used by the Status objects.
method
rich.status.Status.start() -> NoneStart the status animation.
method
rich.status.Status.stop() -> NoneStop the spinner animation.
method
rich.status.Status.update(status:Optional[RenderableType]=None, *spinner:Optional[str]=None, *spinner_style:Optional[StyleType]=None, *speed:Optional[float]=None) -> NoneUpdate status.
class
rich.style.StyleA terminal style.
method
rich.style.Style.background_style() -> 'Style'A Style with background only.
method
rich.style.Style.bgcolor() -> Optional[Color]The background color or None if it is not set.
method
rich.style.Style.chain(*styles:'Style') -> 'Style'Combine styles from positional argument in to a single style.
method
rich.style.Style.color() -> Optional[Color]The foreground color or None if it is not set.
method
rich.style.Style.combine(styles:Iterable['Style']) -> 'Style'Combine styles and get result.
method
rich.style.Style.copy() -> 'Style'Get a copy of this style.
method
rich.style.Style.from_color(color:Optional[Color]=None, bgcolor:Optional[Color]=None) -> 'Style'Create a new style with colors and no attributes.
method
rich.style.Style.from_meta(meta:Optional[Dict[str, Any]]) -> 'Style'Create a new style with meta data.
method
rich.style.Style.get_html_style(theme:Optional[TerminalTheme]=None) -> strGet a CSS style rule.
method
rich.style.Style.link() -> Optional[str]Link text, if set.
method
rich.style.Style.link_id() -> strGet a link id, used in ansi code for links.
method
rich.style.Style.meta() -> Dict[str, Any]Get meta information (can not be changed after construction).
method
rich.style.Style.null() -> 'Style'Create an 'null' style, equivalent to Style(), but more performant.
method
rich.style.Style.on(meta:Optional[Dict[str, Any]]=None, **handlers:Any) -> 'Style'Create a blank style with meta information.
method
rich.style.Style.parse(style_definition:str) -> 'Style'Parse a style definition.
method
rich.style.Style.pick_first(*values:Optional[StyleType]) -> StyleTypePick first non-None style.
method
rich.style.Style.render(text:str='', *color_system:Optional[ColorSystem]=ColorSystem.TRUECOLOR, *legacy_windows:bool=False) -> strRender the ANSI codes for the style.
method
rich.style.Style.test(text:Optional[str]=None) -> NoneWrite text with style directly to terminal.
method
rich.style.Style.transparent_background() -> boolCheck if the style specified a transparent background.
method
rich.style.Style.update_link(link:Optional[str]=None) -> 'Style'Get a copy with a different value for link.
method
rich.style.Style.without_color() -> 'Style'Get a copy of the style with color removed.
class
rich.style.StyleStackA stack of styles.
method
rich.style.StyleStack.current() -> StyleGet the Style at the top of the stack.
method
rich.style.StyleStack.pop() -> StylePop last style and discard.
method
rich.style.StyleStack.push(style:Style) -> NonePush a new style on to the stack.
class
rich.styled.StyledApply a style to a renderable.
class
rich.syntax.ANSISyntaxThemeSyntax theme to use standard colors.
method
rich.syntax.ANSISyntaxTheme.get_style_for_token(token_type:TokenType) -> StyleLook up style in the style map.
class
rich.syntax.PaddingPropertyDescriptor to get and set padding.
class
rich.syntax.PygmentsSyntaxThemeSyntax theme that delegates to Pygments theme.
method
rich.syntax.PygmentsSyntaxTheme.get_style_for_token(token_type:TokenType) -> StyleGet a style from a Pygments class.
class
rich.syntax.SyntaxConstruct a Syntax object to render syntax highlighted code.
method
rich.syntax.Syntax.default_lexer() -> LexerA Pygments Lexer to use if one is not specified or invalid.
method
rich.syntax.Syntax.get_theme(name:Union[str, SyntaxTheme]) -> SyntaxThemeGet a syntax theme instance.
method
rich.syntax.Syntax.highlight(code:str, line_range:Optional[Tuple[Optional[int], Optional[int]]]=None) -> TextHighlight code and return a Text instance.
method
rich.syntax.Syntax.lexer() -> Optional[Lexer]The lexer for this syntax, or None if no lexer was found.
func
rich.syntax.Syntax.line_tokenize() -> Iterable[Tuple[Any, str]]Split tokens to one per line.
func
rich.syntax.Syntax.tokens_to_spans() -> Iterable[Tuple[str, Optional[Style]]]Convert tokens to spans.
class
rich.syntax.SyntaxThemeBase class for a syntax theme.
method
rich.syntax.SyntaxTheme.get_background_style() -> StyleGet the background color.
method
rich.syntax.SyntaxTheme.get_style_for_token(token_type:TokenType) -> StyleGet a style for a given Pygments token.
class
rich.table.ColumnDefines a column within a ~Table.
method
rich.table.Column.cells() -> Iterable['RenderableType']Get all cells in the column, not including header.
method
rich.table.Column.copy() -> 'Column'Return a copy of this Column.
method
rich.table.Column.flexible() -> boolCheck if this column is flexible.
class
rich.table.RowInformation regarding a row.
class
rich.table.TableA console renderable to draw a table.
method
rich.table.Table.add_row(*style:Optional[StyleType]=None, *end_section:bool=False, *renderables:Optional['RenderableType']) -> NoneAdd a row of renderables.
method
rich.table.Table.add_section() -> NoneAdd a new section (draw a line after current row).
method
rich.table.Table.expand() -> boolSetting a non-None self.width implies expand.
method
rich.table.Table.get_row_style(console:'Console', index:int) -> StyleTypeGet the current row style.
method
rich.table.Table.grid(*padding:PaddingDimensions=0, *collapse_padding:bool=True, *pad_edge:bool=False, *expand:bool=False, *headers:Union[Column, str]) -> 'Table'Get a table with no lines, headers, or footer.
About this data
These signatures were extracted from the public source of Textualize/rich
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.