A library for creating super customizable progress indicators.
Project description
PyProg is an Open-Source library for creating progress indicators (e.g. progress bars). It helps you create customizable progress indicators. This library is for Python. It does not have any dependencies.
Compatibility
PyProg is compatible with both Python 3 and Python 2.
Installation
Latest build: pip install pyprog
Latest development build: pip install git+https://github.com/Bill13579/pyprog.git@develop
After you have installed PyProg, you can test if it has been successfully installed by running import pyprog in python. If PyProg was installed successfully, it should show no errors.
How to use the PyProg Progress Bar
To create a progress bar, follow these steps:
- Import PyProg: import pyprog
- Create a ProgressBar object: prog = pyprog.ProgressBar("", "")
- Show the bar: prog.update()
- To update the status, use prog.set_stat(<status>) to set the status and then use prog.update() to actually show the change
- When finished, use prog.end() to make the Progress Bar last
Example Code with Fake For loop:
import pyprog from time import sleep # Create a PyProg ProgressBar Object prog = pyprog.ProgressBar(":-) ", " OK!") # Show the initial status prog.update() # Fake for loop for i in range(0, 100): # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) sleep(0.1) # Update status prog.set_stat(i + 1) # Show (Update) the current status prog.update() # Make the Progress Bar final prog.end()
Output:
Initial State: :-) Progress: 0% -------------------------------------------------- OK! When progress is 50: :-) Progress: 50% #########################------------------------- OK! Final State: :-) Progress: 100% ################################################## OK!
Pretty Progress Bar
You can also add more options to make it look good.
Adding options complete_symbol="â–ˆ", not_complete_symbol="-" will change the original output to:
Initial State: :-) Progress: 0% -------------------------------------------------- OK! When progress is 50: :-) Progress: 50% █████████████████████████------------------------- OK! Final State: :-) Progress: 100% ██████████████████████████████████████████████████ OK!
Auto calculate the percentage
PyProg can also auto calculate the current percentage. You just need to tell PyProg the total number of things you need to process.
Change the line prog = pyprog.ProgressBar("", "") to prog = pyprog.ProgressBar("", "", <Total Number of things>), and PyProg will calculate the percentage for you based on the status that you give it.
To use it in our simple progress bar code, if we have 37 tasks to do, we can change this:
# Create a PyProg ProgressBar Object prog = pyprog.ProgressBar(":-) ", " OK!")
to this:
# Create a PyProg ProgressBar Object prog = pyprog.ProgressBar(":-) ", " OK!", 37)
And also change the fake for loop from for i in range(0, 100): to for i in range(0, 37):, and it will auto calculate the percentage and show it to the user.
How to use the PyProg Progress Indicator (Fraction)
To create a basic progress indicator (fraction), follow these steps:
- Import PyProg: import pyprog
- Create a ProgressIndicatorFraction object: prog = pyprog.ProgressIndicatorFraction("", "", <Total number of things>) (Replace “<Total number of things>” with the total number of tasks or things you need to process)
- Show the indicator: prog.update()
- To update the status, use prog.set_stat(<status>) to set the status and then use prog.update() to actually show the change
- When finished, use prog.end() to make the Progress Indicator (Fraction) last
Example Code with Fake For loop (We are using 56 as the total in this example):
import pyprog from time import sleep # Create a PyProg ProgressIndicatorFraction Object prog = pyprog.ProgressIndicatorFraction(":-) ", " OK!", 56) # Show the initial status prog.update() # Fake for loop for i in range(0, 56): # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) sleep(0.1) # Update status prog.set_stat(i + 1) # Show (Update) the current status prog.update() # Make the Progress Indicator (Fraction) final prog.end()
Output:
Initial State: :-) 0/56 OK! When half done: :-) 28/56 OK! Final State: :-) 56/56 OK!
Documentation
The documentation is at the Github page for this project.
Github page: https://github.com/Bill13579/pyprog/
Contact
If you want to support me, please contact me at kudoshiko@gmail.com.
My website is at http://www.WhatsYourIdea.com/
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size pyprog-1.0.2-py2.py3-none-any.whl (7.1 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size pyprog-1.0.2.tar.gz (4.3 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for pyprog-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99935eb80a0b1b1e73b554aa8aeca582535cf0c470b43904f077f7e153d26618 |
|
MD5 | 4efc8b3285f2adfb06c387a024f60da8 |
|
BLAKE2-256 | 09bbff8a104b3fb19d11200434b7caca9389b0b61c987e823bc42bcb0d5c827e |