Making context outputs more elegant is the challenge for almost everyone wherever they go: console, web, mobile or graphical.
The Rich library is the most innovative in this regard and your TUI apps will look even more professional!
This API makes it easy to add color and style to terminal output. It can also render beautiful tables, progress bars, markdown, syntax highlighted source code, tracebacks and more - ready to use.
To install it is very simple, just use pip, you can install only for your user:
pip install rich --user
Or for your entire system
sudo pip install rich
At first you can see all the formatting possibilities by running the command:
python -m rich
The output will be something like:
Another basic example of usage, using style and hexadecimal colors: vim hello.py
from rich.console import Console
console = Console()
console.print("Terminal", "Root", style="#ccc010 bold")
Run: python hello.py, exit:
You can even use HTML-style tags, but with square brackets, for example:
from rich.console import Console
console = Console()
console.print("[bold]Website[/bold]: [bold cyan]Terminal Root[/bold cyan] [u]Linux[/u] [i]and[/i] [bold yellow]Programming[/bold yellow].")
In addition to tables, see this gif:
Access the repository on GitHub and learn more: