Progbarr is a Python library for efficiently creating customizable progress bars in the console.
Project description
Progbarr
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
jobshould be in present participle form e.g., "Sleeping" instead of "Sleep".lengthshould be equal to or a factor oftasksfor a smooth progress.charsshould be made up of 1 or more characters (maximum 4) representing fill, placeholder, border-left, and border-right, respectively.colorandbgcolorare both optional (default isNone).
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()
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}%")
License
This project is licensed under the MIT License – see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1172cacfa3088986f9709e2dc4477c4dea75c32927a428987683df4aa6e6add5
|
|
| MD5 |
4e4accf64e32cd82d298c46b1846dbdf
|
|
| BLAKE2b-256 |
4cebe650da1f63bf18308abdef5f05965a70241345dd0579fb33da884b6619d1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859996fec52cfe33e614ec1fcc107b6a74b4c3ee91086eef6d6699cb9433010b
|
|
| MD5 |
a0d9b0854016853cc89759fc9a24436d
|
|
| BLAKE2b-256 |
18cf822ec7cec6f55c5f71fa02d70f725d5768023c3adfcc24364747f962426f
|