Progress bar for terminal
Project description
Awesome progress bar
It's a progress bar for the terminal. But why it is awesome?
- It has thread mode. This way progress bar can run in the parallel.
- It's animated with ASCII characters.
- It also measures elapsed time.
- It's user-friendly and customizable.
Why does progress bar need to be run in the parallel mode?
The bar should be updated when it is time to. Imagine we are doing something in the for
loop and each iteration we update its state. But each iteration can take different amount
of time. And each iteration can be longer than 1 minute. And without threads the animation
would have non-constant amount of FPS.
How to use
Initialization
Parameters:
- total: Amount of iterations.
- prefix: A short message before the progress bar. Default is 'Progress'.
- suffix: A short message after the progress bar. Default is 'Complete'.
- fill: A character that will be used as progress bar filler.
- bar_length: The length of the whole string (including prefix, spinner, progress bar, percents and suffix). Default is equal to the minimum between terminal's width and 100.
- update_period: The duration of pause between iterations in seconds. Default is 0.1. Works only if use_thread is True.
- use_time: If True there will be an information about elapsed time in the center of the progress bar written in time_format format. Default is True.
- time_format: String, that should include hh, mm or/and ss. hh will be replaced with amount of elapsed hours, mm - minutes, ss - seconds. Default is 'mm:ss'.
- use_thread: If True ProgressBar will create extra thread. Default is True.
from awesome_progress_bar import ProgressBar
bar = ProgressBar(100)
# Progress: вЈ· |=> 00:01 | 1.00% Complete
bar = ProgressBar(100, prefix='Prefix', suffix='Suffix', bar_length=70)
# Prefix: вЈџ |=> 00:01 | 1.00% Suffix
bar = ProgressBar(100, fill='#', use_time=False, bar_length=70)
# Progress: вЈЅ |#> | 3.00% Complete
bar = ProgressBar(100, time_format='hh mm:ss', bar_length=70)
# Progress: вЈ· |> 00 00:01 | 1.00% Complete
Progress
Each iteration user should call
bar.iter()
In the thread mode progress bar's state is updating by itself every update_period
seconds. In this mode bar.iter()
doesn't print anything and it used only for tracking
the progress. In the mode without thread bar.iter()
prints the bar every time user
call it.
Attention!
In the thread mode you should handle KeyboardInterrupt exception with bar.stop()
function:
from awesome_progress_bar import ProgressBar
import time
bar = ProgressBar(100)
try:
for x in range(100):
bar.iter()
time.sleep(0.1)
except KeyboardInterrupt:
bar.stop()
Or you can also use finally
.
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
Hashes for awesome-progress-bar-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f01df66b4d09b48657173dd5319fd6d21c7a72e0e332be5ff5400928b56493 |
|
MD5 | d6ad9ea35dbbc82425421d303517417c |
|
BLAKE2b-256 | a15edb74930e366efebdd903878fa56eabe03aaf0f2405e5278aeec72efbf0dc |
Hashes for awesome_progress_bar-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b702096775bde7071bc87fa71674f109345bbf734dfa7d7b11439387454958c |
|
MD5 | 678330e974ce5fa8075f6b1aafb648ab |
|
BLAKE2b-256 | fb65dd113abe3b807aef9fa3076aef97f095093fdcbf0dea7a056ba0727c0af9 |