Skip to main content

Progbarr is a Python library for efficiently creating customizable progress bars in the console.

Project description

Progbarr

PyPI - Version PyPI - Downloads License Python Versions

Progbarr is a Python library for efficiently creating customizable progress bars in the console.

Features

  • Supports setting any UNICODE character for fill, placeholder, or borders
  • Supports setting foreground and background color
  • Supports 140+ HTML color names, all RGB values, and all HEX color codes

Installation

pip install progbarr

Usage

A progress bar is an instance of the ProgressBar class.

Syntax

with ProgressBar(job, tasks, length, chars, color, bgcolor) as pb:
    for _ in range(tasks):
      # Perform some task
      pb.advance()

The table below explains the parameters of the ProgressBar constructor:

Parameter Type Purpose
job str Overall job being done
tasks int Number of tasks to be performed
length int Length of the progress bar
chars str Characters used by progress bar
color str / None Foreground color of progress bar
bgcolor str / None Background color of progress bar

Notes

  • job should be in present participle form e.g., "Sleeping" instead of "Sleep".
  • length should be equal to or a factor of tasks for a smooth progress.
  • chars should be made up of 1 or more characters (maximum 4) representing fill, placeholder, border-left, and border-right, respectively.
  • color and bgcolor are both optional (default is None).

Example

from time import sleep
from progbarr import ProgressBar

with ProgressBar("Sleeping", 5, 20, "# []", "green", "white") as pb:
    for _ in range(5):
        sleep(1)
        pb.advance()

example

Benchmarking

The main goal of progbarr is to take unnoticeable processing time when displaying a progress bar. This means that the time taken to do looped tasks without a progress bar is approximately equal to the time taken to do the tasks with a progress bar. Therefore, the overhead (if any) is negligible.

The example below shows the amount of time taken to perform a sleep of 1 second for 5 times with and without a progress bar.

from time import sleep, time
from progbarr import ProgressBar


def benchmark_with_progressbar():
    with ProgressBar('Sleeping', 5, 20, '# []', None, None) as pb:
        for _ in range(5):
            sleep(1)
            pb.advance()


def benchmark_without_progressbar():
    for _ in range(5):
        sleep(1)


start_time_with_progressbar = time()
benchmark_with_progressbar()
stop_time_with_progressbar = time()

start_time_without_progressbar = time()
benchmark_without_progressbar()
stop_time_without_progressbar = time()

time_taken_with_progressbar = stop_time_with_progressbar - start_time_with_progressbar
time_taken_without_progressbar = stop_time_without_progressbar - start_time_without_progressbar

difference = time_taken_with_progressbar - time_taken_without_progressbar
overhead = round(difference/time_taken_without_progressbar*100,3)

print(f"With progress bar   : {time_taken_with_progressbar}")
print(f"Without progress bar: {time_taken_without_progressbar}")
print(f"Difference          : {difference}")
print(f"Overhead            : {overhead}%")

benchmark

License

This project is licensed under the MIT License – see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

progbarr-1.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

progbarr-1.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file progbarr-1.0.1.tar.gz.

File metadata

  • Download URL: progbarr-1.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for progbarr-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3b36163f1a1d427fcf5a7dc70c3408a6dfe147d153c651e9169b202de9952cd3
MD5 6aa046f7fb025f309fce4995b0095fea
BLAKE2b-256 5743cfeda7048063cc3943732fd474929727d854b488eb67da4c0e2c13ff5bb2

See more details on using hashes here.

File details

Details for the file progbarr-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: progbarr-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for progbarr-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f0081ffbf19f7865911d1f8899e2367b20fd919ea2cc821e00374ca0f94d6b5
MD5 83c0b84718803e7ca1225eb48b495ced
BLAKE2b-256 8840495f94b48eb69945dd9a4d75503d17a7ee5ffc594fb291d2d1cf55aa93bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page