progressbar

2.5 · abandoned · verified Wed Apr 15

The `progressbar` library (version 2.5) provides text-based progress bars for long-running operations in Python. This version is largely unmaintained and is compatible only with Python 2. For modern Python projects, the actively maintained `progressbar2` library is recommended, which offers backward compatibility and Python 3 support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic progress bar with several common widgets. While `progressbar` (v2.5) is Python 2 only, this code is illustrative of the general API. For Python 3, it is critical to use `progressbar2` (pip install progressbar2) as a replacement. The `ProgressBar` class manages the progress, and various `widgets` define the display format.

import time
import progressbar

def main():
    print("Using progressbar (v2.5) for demonstration (Python 2 example if run directly)")
    print("**It is HIGHLY recommended to use 'progressbar2' instead: pip install progressbar2**\n")

    # This quickstart pattern is derived from progressbar2 examples,
    # which aims for backward compatibility with the original 'progressbar'.
    widgets = [
        'Test: ', progressbar.Percentage(),
        ' ', progressbar.Bar(marker=progressbar.RotatingMarker()),
        ' ', progressbar.ETA(),
        ' ', progressbar.FileTransferSpeed(),
    ]

    # For Python 2, range(100) is fine. For Python 3, use list(range(100)) or ensure xrange behavior.
    # As this library is Python 2, simple range is shown.
    bar = progressbar.ProgressBar(widgets=widgets, maxval=100).start()
    for i in range(100):
        # Simulate some work
        time.sleep(0.01)
        bar.update(i + 1)
    bar.finish()

    print("\nExample complete.")

if __name__ == '__main__':
    main()

view raw JSON →