DEV Community

MrRobot
MrRobot

Posted on

Rich – Beautiful and Interactive Console Output with python

Rich is a Python library that makes terminal output visually appealing with colors, formatting, and advanced features like tables, progress bars, and syntax highlighting. It enhances readability for command-line tools, scripts, and logs. Rich is commonly used for building CLI applications, debugging, and adding interactive visual elements to console programs without requiring a GUI.


Installation:

pip install rich
Enter fullscreen mode Exit fullscreen mode

Example usage:

from rich.console import Console
from rich.table import Table

console = Console()

table = Table(title="Fruits")
table.add_column("Name", style="cyan")
table.add_column("Quantity", style="magenta")
table.add_row("Apple", "10")
table.add_row("Banana", "20")

console.print(table)
Enter fullscreen mode Exit fullscreen mode

PyPI page: https://pypi.org/project/rich/
GitHub page: https://github.com/Textualize/rich


3 Project Ideas:

  1. Build a CLI inventory management tool with colorful tables.
  2. Create a terminal-based dashboard showing real-time statistics.
  3. Enhance command-line scripts with progress bars and syntax-highlighted logs.

Top comments (0)