Skip to content

Update multicoloredline.py #2506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions Colors/multicoloredline.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,54 @@
## This script prints a multicolored line
# quo can be installed using pip

from quo.console import Console
from rich.console import Console
from rich.syntax import Syntax
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn
from rich.table import Table
import time
import json

console = Console()

console.rule(multiclored=True)
# Fancy separator
console.rule("[bold]Welcome to Rich Terminal[/bold]", style="rainbow")

# Define some JSON data
json_data = {
"message": "Hello, World!",
"status": "success",
"code": 200
}

# Print JSON with syntax highlighting
syntax = Syntax(json.dumps(json_data, indent=4), "json", theme="monokai", line_numbers=True)
console.print(syntax)

# Simulating a progress bar
console.print("\n[bold cyan]Processing data...[/bold cyan]\n")

with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TextColumn("{task.percentage:>3.0f}%"),
console=console,
) as progress:
task = progress.add_task("[cyan]Loading...", total=100)
for _ in range(100):
time.sleep(0.02)
progress.update(task, advance=1)

# Create a rich table
console.print("\n[bold magenta]Results Summary:[/bold magenta]\n")

table = Table(title="System Report", show_header=True, header_style="bold cyan")
table.add_column("Metric", style="bold yellow")
table.add_column("Value", justify="right", style="bold green")

table.add_row("CPU Usage", "12.5%")
table.add_row("Memory Usage", "68.3%")
table.add_row("Disk Space", "45.7% free")

console.print(table)

# Success message
console.print("\n[bold green]🎉 Process completed successfully![/bold green]\n")
console.rule(style="rainbow")