Python module to display a nice loading bar in a terminal window.
Go to the module directory and run:
$ pip install setup.py
Or:
$ python3 setup.py install
There are 3 different loading bar:
- Standard loading bar
- Loading bar with size loaded, speed and remaining time
- Loading bar with infos above plus a custom message (usefull to display a verbose loading bar)
Standard loading bar without any other infos.
import loading
total_file_size = 1000
# Create a loading bar object with total_file_size in bytes
lb = loadingbar.LoadingBar(total_file_size)
# For every piece of file
for chunk in file:
# Update the loading bar with the len of new data
lg.update(len(chunk))
# When finished, display a 100% loading bar
lg.done()Standard loading bar with infos such as size downloaded, speed, eta.
import loading
total_file_size = 1000
lb = loadingbar.InfoLoadingBar(total_file_size)
# Run as aboveThis special InternetLoadingBar smooth the speed calculation by taking the overall average time rather than a instant speed.
import loading
total_file_size = 1000
lb = loadingbar.InternetLoadingBar(total_file_size)
# Run as aboveLoading bar that displays a message, like for example the filename that it is downloaded. Two options:
loadingbar.MessageLoadingBarloadingbar.VerboseLoadingBar
import loading
total_file_size = 1000
lb = loadingbar.VerboseLoadingBar(total_file_size)
# For every piece of file
for chunk in file:
# Update the loading bar with the len of new data
lg.update(len(chunk), "Message to be displayed, such as filename, etc.")
# When finished, display a 100% loading bar
lg.done()Add a percentage after the loading bar.
Add a percentage after the loading bar.
If a new and custom loading bar is needed, you can implement a new one by inheriting from the LoadingBar class or the abstract class ILoadingBar. See loading > loading_bar.py for examples.
MIT license. Feel free to use, share, or improve it.






