Python alive progress bar
In this post, you will learn about the alive progress bar. There are several progress bar modules available in Python, but the alive-progress bar module has lots of advantages. This module is feature rich, easy to use, and has plenty of built-in spinner styles to browse from. What's more, you can make your own effects without much of a stretch, there's built-in support for several special effects like frames, scrolling, bouncing, delayed, and compound spinners!
Install alive progress bar
The following command installs the alive progress bar module using the pip tool.
pip install alive-progress
Python alive progress bar example
Here is a simple example of the alive progress bar. First, we have imported the alive_progress and time modules and iterated as usual over your items, processing each item. Finally, we have called the bar() method after consuming one item.
from alive_progress import alive_bar
import time
for x in 50, 60, 30, 0:
with alive_bar(x) as bar:
for i in range(x):
time.sleep(.001)
bar()
Output of the above code- Alive progress bar styles
If you wonder how to apply styles in an alive progress bar, here is the solution. The showtime displays all possible styles of progress bar.
from alive_progress import showtime
showtime()
Output of the above code- Alive process bar style example
The default style bar is easy to use. But, if you want to use bubbles as a style bar, the following example demonstrates this.
from alive_progress import alive_bar
import time
for x in range(10):
with alive_bar(x, bar='bubbles') as bar:
for i in range(x):
time.sleep(.001)
bar()
Output of the above code-
Related Articles
Python Weather API ScriptPrettytable in Python
Python File Handler
Python program to multiply two numbers
Multiply all elements in list Python
Python Tkinter Combobox
Convert list to dictionary Python
Convert array to list Python
numpy dot product
glob in Python
Python heap implementation
zip function in Python
Remove last element from list Python
Check if list is empty Python
Remove element from list Python
Split multiple delimiters python
Python loop through list
Python iterate list with index
Python add list to list
Python random choice
Python dict inside list
Remove character from string Python
Python raise keyword