🚀 Usage
ProgressBar has quite a few parameters:
| Parameter name | Mandatory | Type | Description |
|---|---|---|---|
value |
yes | int | Current value of the progress bar |
total |
yes | int | Max value of the progress bar |
string_length |
yes | int | Length of the bar |
unfilled_char |
no | str | char that displays the unfilled portion of the bar. Defaults to "▬". |
progress_char |
no | str | char that displays the filled portion of the bar. Defaults to "🔘". |
fill_bar |
no | bool | If the left side of the bar should also be filled. Defaults to False. |
Examples:
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85
p = ProgressBar(67, 85, 25)
print(p)
>>> "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"
from strprogressbar import ProgressBar
# create a progressbar with a width of 20 characters
# we are in step 3/5, change the default characters
# fill in the progress that we already made
p = ProgressBar(3, 5, 20, "░", "▓", True)
print(p)
>>> "▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░"
from strprogressbar import ProgressBar
# create a progressbar with a width of 30 characters
# we are in step 8/15, change the default characters
# fill in the progress that we already made with 2 chars
p = ProgressBar(8, 15, 30, "░", "▒▓", True)
print(p)
>>> "▒▓▒▓▒▓▒▓▒▓▒▓▒▓▒▓░░░░░░░░░░░░░░"
What if we want to show our progress in numbers or in percentage?
ProgressBar has 4 default functions to add or remove this feature.
Note that adding percentage or counter does not alter the size of the progress bar. eg: If you set string_length to 20 and added a percentage indicator, the progress bar will still be 20 chars long, but the total string will be longer with the percentage sign.
add_percentage()
Parameters
| Parameter name | Mandatory | Type | Description |
|---|---|---|---|
decimals |
no | int | The amount of decimals to display. Defaults to 0. |
left |
no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side. |
seperator |
no | str | The seperator between the progress bar and the percentage number. Defaults to " ". |
Example
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 30/64 and display this on the right side with 2 decimals
p = ProgressBar(30, 64, 25).add_percentage(2, False)
print(p)
>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬ 46.88%"
|__________________________|
25 characters
remove_percentage()
Parameters
This function has no parameters.
Example
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 30/64 and display this on the right side with 0 decimals
p = ProgressBar(30, 64, 25).add_percentage(0, False, ' @ ')
print(p)
# remove the percentage
print(p.remove_percentage())
>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬ @ 47%"
>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬"
add_counter()
Parameters
| Parameter name | Mandatory | Type | Description |
|---|---|---|---|
left |
no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side. |
seperator |
no | str | The seperator between the progress bar and the percentage number. Defaults to " " |
Example
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85 and display this on the left side
p = ProgressBar(67, 85, 25).add_counter(True, " - ")
print(p)
>>> "67/85 - ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"
We can also add both a counter and a percentage indicator:
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85 and display this on the left side
# add a percentage indicator on the right side
p = ProgressBar(67, 85, 25).add_counter(True, " - ").add_percentage(1, False, " - ")
print(p)
>>> "67/85 - ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬ - 78.8%"
remove_counter()
Parameters
This function has no parameters.
Example
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 18/64 and display this on the right side with 0 decimals
p = ProgressBar(18, 64, 25, "░", "▓", True).add_counter(False).add_percentage()
print(p)
# remove the percentage
print(p.remove_counter())
>>> "▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░ 28% 18/64"
>>> "▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░ 28%"
🛠️ Installation Steps:
1. Installing
pip install strprogressbar
🛡️ License:
This project is licensed under the GNU General Public License v3.0
Metadata
Release files for strprogressbar 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strprogressbar-1.0.tar.gz | 17.0 kB | Without provenance | Details for strprogressbar-1.0.tar.gz |
Release files / strprogressbar-1.0.tar.gz
| Download URL | strprogressbar-1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d5b481175aaaf97bdf4f17318368c299faea23ceb0fb3c2f4ecf6d760243d57
|
|
BLAKE2b-256 checksum How to use checksums |
70a05e5b0b81cdaa379fafcf93764059941a71079095dbd1a709cfc21a7af51e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for strprogressbar 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.