In order to show a progress bar, Rich needs to know how may steps are involved and when you finish a step. The track function can get this information automatically from a sequence. You're using this in your example, but your sequence only has a single element so you go from 0 to 100% in a single step.

If you want to track progress of something you need a sequence that defines the work to be done. For instance if you had a list of urls to scrape, you might do something like this:

from rich.progress import track
SCRAPE_URLS = ["https://example.org", "https://google.org", ...]
for url in track(SCRAPE_URLS):
    scrape(url)

The progress bar will advance for every URL.

Answer from Will McGugan on Stack Overflow
🌐
Timothygebhard
timothygebhard.de › posts › richer-progress-bars-for-rich
Richer progress bars for _rich_ · Timothy Gebhard
Today, I finally got around to looking into this in more detail, and it turns out that is actually very easy to tweak rich to produce a progess bar that displays all the information I need and still looks better than tqdm!1 Here is the code that I am currently using (based on version 12.0.0 of rich, which was released just this week): from rich.progress import ( BarColumn, MofNCompleteColumn, Progress, TextColumn, TimeElapsedColumn, TimeRemainingColumn, ) # Define custom progress bar progress_bar = Progress( TextColumn("[progress.percentage]{task.percentage:>3.0f}%"), BarColumn(), MofNCompleteColumn(), TextColumn("•"), TimeElapsedColumn(), TextColumn("•"), TimeRemainingColumn(), ) # Use custom progress bar with progress_bar as p: for i in p.track(range(1000)): # Do something here pass
🌐
Rich
rich.readthedocs.io › en › latest › progress.html
Progress Display — Rich 14.1.0 documentation
This is particularly useful when you can’t easily modify the code that does the reading. The following example demonstrates how we might show progress when reading a JSON file: import json import rich.progress with rich.progress.open("data.json", "rb") as file: data = json.load(file) print(data)
Discussions

Can't get progress bar to work in python rich - Stack Overflow
Edit: For more clarity, I want the progressbar to update as it goes through each part of my code. There is only one url to scrape. For example it would start at 0%, and after global pfp the bar would change to x% ... In order to show a progress bar, Rich needs to know how may steps are involved ... More on stackoverflow.com
🌐 stackoverflow.com
Progress bar in Python using rich - Stack Overflow
Note: The generator process(chunks) is a generic stand-in for the file sizes in original question. This answer is mostly for the benefit of those brought here by searching on something like "python rich.progress_bar.ProgressBar example". More on stackoverflow.com
🌐 stackoverflow.com
showing multiple *different* progress bars
Is there a way to show multiple different progress bars at once, which each show the progress for a different aspect (for example, N overall tasks done + separate progress on an individual task)? I know that a single Progress instance can show the progress for multiple tasks at once (see python -m rich... More on github.com
🌐 github.com
3
2
Progress bar fixed to bottom of window
Hello, is there a possibility to create a progress bar fixed to the bottom of the terminal window, like in this image? I want the text to appear above the progress bar. Thank you in advance! More on github.com
🌐 github.com
1
2
October 12, 2021
🌐
Typer
typer.tiangolo.com › tutorial › progressbar
Progress Bar - Typer
You can use Rich's Progress Display ... print(f"Processed {total} things.") if __name__ == "__main__": app() You put the thing that you want to iterate over inside of Rich's track(), and then iterate over that....
🌐
Rich
rich.readthedocs.io › en › stable › reference › progress.html
rich.progress — Rich 14.1.0 documentation
Defaults to “bar.pulse”. update_period (float, optional) – Minimum time (in seconds) between calls to update(). Defaults to 0.1. disable (bool, optional) – Disable display of progress. show_speed (bool, optional) – Show speed if total isn’t known. Defaults to True. ... An iterable of the values in the sequence. ... rich.progress.wrap_file(file, total, *, description='Reading...', auto_refresh=True, console=None, transient=False, get_time=None, refresh_per_second=10, style='bar.back', complete_style='bar.complete', finished_style='bar.finished', pulse_style='bar.pulse', disable=False)[source]
🌐
GitHub
github.com › Textualize › rich › blob › master › examples › dynamic_progress.py
rich/examples/dynamic_progress.py at master · Textualize/rich
Demonstrates how to create a dynamic group of progress bars, showing multi-level progress for multiple tasks (installing apps in the example), each of which consisting of multiple steps. · """ · import time · · from rich.console import Group · from rich.panel import Panel ·
Author: Textualize
🌐
PyPI
pypi.org › project › rich
rich · PyPI
For situations where it is hard to calculate progress, you can use the status method which will display a 'spinner' animation and message. The animation won't prevent you from using the console as normal. Here's an example: from time import sleep from rich.console import Console console = Console() tasks = [f"task {n}" for n in range(1, 11)] with console.status("[bold green]Working on tasks...") as status: while tasks: task = tasks.pop(0) sleep(1) console.log(f"{task} complete")
Find elsewhere
🌐
Maoli Liu
liumaoli.me › notes › notes-about-rich
Multi-threading and Multi-processing Progress Visualization with Python’s rich Library - Maoli Liu
January 27, 2024 - For example, when there are multiple tasks to be monitored, we can use Progress to display multiple progress bars simultaneously. ... import time from concurrent.futures import ThreadPoolExecutor from rich import print from rich.progress import Progress progress = Progress() def working(worker, ...
Top answer
1 of 2
4

Rich's progress bars are nice!

For many use-cases, the track function that wraps a Sequence or Iterable will suffice:

import time
from rich.progress import track

for i in track(range(100)):
    time.sleep(0.05)

To increment progress by a variable amount at each step, use rich.progress.Progress.

This example might show something in the spirit of the original question. Just for fun, let's customize the progress bar while we're at it.

import time
import random
from rich.progress import (
    BarColumn,
    Progress,
    SpinnerColumn,
    TaskProgressColumn,
    TimeElapsedColumn,
    TimeRemainingColumn,
)

def process(chunks):
    for chunk in chunks:
        time.sleep(0.1)
        yield chunk

chunks = [random.randint(1,20) for _ in range(100)]

progress_columns = (
    SpinnerColumn(),
    "[progress.description]{task.description}",
    BarColumn(),
    TaskProgressColumn(),
    "Elapsed:",
    TimeElapsedColumn(),
    "Remaining:",
    TimeRemainingColumn(),
)

with Progress(*progress_columns) as progress_bar:
    task = progress_bar.add_task("[blue]Downloading...", total=sum(chunks))
    for chunk in process(chunks):
        progress_bar.update(task, advance=chunk)

Note: The generator process(chunks) is a generic stand-in for the file sizes in original question. This answer is mostly for the benefit of those brought here by searching on something like "python rich.progress_bar.ProgressBar example".

2 of 2
2

Your main question asks for

  • How to calculate the amount of data sent?

From Real Python's Socket Programming in Python (Guide):

The .send() method also behaves this way. It returns the number of bytes sent, which may be less than the size of the data passed in.

This means that you have to pass the returned int of socket.send() to the parameter advance of progress.update() function (compare your "<AMOUNT_OF_DATA_OR_CHUNKS_SENT>"):

# (1) define the transfer function returning the bytes_sent
def transfer_to_socket(from_file, to_socket, size):
    bytes_to_read = int(size)
    chunk = from_file.read(bytes_to_read)
    
    # <AMOUNT_OF_DATA_OR_CHUNKS_SENT>
    return to_socket.send(chunk)  # may be: bytes_sent < len(chunk) < bytes_to_read 

# (2) replace the progress-loop with: 
while not progress.finished:
    bytes_sent = transfer_to_socket(f, client, FILSIZ[idx])
    progress.update(task, advance=bytes_sent)
    time.sleep(0.1)
🌐
GitHub
github.com › Textualize › rich › discussions › 1500
showing multiple *different* progress bars · Textualize/rich · Discussion #1500
For the subtask progress bars, I want to remove them when that specific subtask (like downloading a file) is done. Am I pushing things too far here, trying to make it too dynamic? ... Let me answer my own question: I got things to work pretty much as I wanted by using a Live instance with a RenderGroup instance that combines a bunch of Progress instances, each of which showing the progress on a different aspect. Full example is below... import os import time from rich.console import RenderGroup from rich.live import Live from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn from rich.progress import DownloadColumn, TransferSpeedColumn, TimeRemainingColumn from rich.rule import Rule app1_urls = [ ('https://example.org/app1-part1.tar.gz', 3401321), ('https://example.org/app1-part2.tar.gz', 6382217), ] app2_urls = [ ('h…
🌐
Rich
rich.readthedocs.io › en › stable › reference › progress_bar.html
rich.progress_bar — Rich 14.1.0 documentation
class rich.progress_bar.ProgressBar(total=100.0, completed=0, width=None, pulse=False, style='bar.back', complete_style='bar.complete', finished_style='bar.finished', pulse_style='bar.pulse', animation_time=None)[source]
🌐
Will McGugan
willmcgugan.com › blog › tech › post › progress-bars-with-rich
Progress bars with Rich - Will McGugan
March 12, 2020 - This is the last major feature planned before a 1.0 release of Rich. Tweet @willmcgugan if you have any feedback or requests. ... Looks great! One question: is it thread safe? This was always an issue for me when I wanted to put a tqdm progress bar on top of an embarrassingly parallel problem. ... Sure, something like this should do it. progress = Progress(BarColumn(), "{task.elapsed}")
🌐
PäksTech
pakstech.com › blog › python-progress-bar
Show a Progress Bar in Python | PäksTech
April 6, 2021 - As you can see the output is automatically colorized, on-going progress is shown in red, and when the processing is complete the color changes to green. The progress bar also calculates an estimate for the remaining time automatically! If your work can be put in a list then the whole thing becomes even simpler since Rich automatically uses the list length to calculate the progress.
🌐
Snyk
snyk.io › advisor › rich › functions › rich.progress.progress
How to use the rich.progress.Progress function in rich | Snyk
To help you get started, we've selected a few rich.progress.Progress examples, based on popular ways it is used in public projects.
🌐
YouTube
youtube.com › shorts › oyyL6ZPOsdI
Rich Colorful Progress Bars In Python - YouTube
We are supporting everyone freely. Join us for live support. WhatsApp Support: https://whatsapp.com/channel/0029Va5BbiT9xVJXygonSX0GInstagram Support: https...
Published: October 18, 2025
🌐
Theautomatic
theautomatic.net › home › python’s rich library – a tutorial
Python's rich library - a tutorial - Open Source Automation
January 5, 2021 - Once you have it installed, open up the command line and type in python. In order to get the additional functionality from rich, you’ll need to do one more step, which you can see below. Running this snippet will allow you to have styled / formatted code interactively. You’ll only need to do this once. ... Here’s a couple examples of automatic coloring for a list. In a previous post, we talked about how to create progress bars with Python.
🌐
Lightning AI
lightning.ai › docs › pytorch › stable › api › lightning.pytorch.callbacks.RichProgressBar
Lightning AI | Turn ideas into AI, Lightning fast
The all-in-one platform for AI development. Code together. Prototype. Train. Scale. Serve. From your browser - with zero setup. From the creators of PyTorch Lightning.
🌐
freeCodeCamp
freecodecamp.org › news › use-the-rich-library-in-python
How to Use the Rich Library with Python
February 8, 2022 - Notice the Brother and Sister branch in the above example. In the official documentation, we have a tree.py file that outputs the file structure using Tree. The output looks like this: Rich can show continuously updated information about the status of long-running tasks, file copies, and so forth. You can customize this information, too. By default, it provides a description of the 'task,' a progress bar, percentage complete, and anticipated time left.
🌐
Textual
textual.textualize.io › blog › 2022 › 11 › 24 › spinners-and-progress-bars-in-textual
Textual - Spinners and progress bars in Textual
November 24, 2022 - Instances of IntervalUpdate should set the attribute _renderable_object to the instance of the Rich renderable that we want to animate. The methods update_rendering and on_mount are exactly the same as what we had before, both in the progress bar widget and in the spinner widget.