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.0.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.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: progbarr-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1172cacfa3088986f9709e2dc4477c4dea75c32927a428987683df4aa6e6add5
MD5 4e4accf64e32cd82d298c46b1846dbdf
BLAKE2b-256 4cebe650da1f63bf18308abdef5f05965a70241345dd0579fb33da884b6619d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: progbarr-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 859996fec52cfe33e614ec1fcc107b6a74b4c3ee91086eef6d6699cb9433010b
MD5 a0d9b0854016853cc89759fc9a24436d
BLAKE2b-256 18cf822ec7cec6f55c5f71fa02d70f725d5768023c3adfcc24364747f962426f

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