Skip to content

Investigate Rich Progress Bars #138

@mdancho84

Description

@mdancho84

Investigate Rich Progress Bars

from rich.progress import Progress, BarColumn, TextColumn, TimeElapsedColumn
from rich.console import Console
from rich.style import Style
from time import sleep

console = Console()

# Define custom styles
custom_bar_style = Style(color="#2c3e50")  # Color of the progress bar
custom_completed_style = Style(color="#18BC9C")  # Color of the completed section
custom_text_style = Style(color="#2c3e50")  # Color of the text

# Define custom progress bar
progress = Progress(
    TextColumn("[progress.description]{task.description}", style=custom_text_style),
    BarColumn(bar_width=None, style=custom_bar_style, complete_style=custom_completed_style),
    "[progress.percentage]{task.percentage:>3.0f}%",
    TimeElapsedColumn(),
)

# Add a task to the progress bar
with progress:
    task_id = progress.add_task("[#2c3e50]PyTimeTK, Engine=Polars...", total=100)

    # Update the task
    while not progress.finished:
        progress.update(task_id, advance=0.5)
        sleep(0.01)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions