Enlighten Progress Bar
Project description
Overview
Enlighten Progress Bar is a console progress bar library for Python.
The main advantage of Enlighten is it allows writing to stdout and stderr without any redirection or additional code. Just print or log as you normally would.
Enlighten also includes experimental support for Jupyter Notebooks.
The code for this animation can be found in demo.py in examples.
Documentation
Installation
PIP
$ pip install enlighten
RPM
Fedora and EL8 (RHEL/CentOS)
(EPEL repositories must be configured for EL8)
$ dnf install python3-enlighten
EL7 (RHEL/CentOS)
(EPEL repositories must be configured)
$ yum install python2-enlighten
$ yum install python36-enlighten
PKG
Arch Linux
$ pacman -S python-enlighten
DEB
Debian and Ubuntu
$ apt-get install python3-enlighten
Conda
$ conda install -c conda-forge enlighten
Examples
Basic
For a basic status bar, invoke the Counter class directly.
import time
import enlighten
pbar = enlighten.Counter(total=100, desc='Basic', unit='ticks')
for num in range(100):
time.sleep(0.1) # Simulate work
pbar.update()
Advanced
To maintain multiple progress bars simultaneously or write to the console, a manager is required.
Advanced output will only work when the output stream, sys.__stdout__ by default, is attached to a TTY. get_manager can be used to get a manager instance. It will return a disabled Manager instance if the stream is not attached to a TTY and an enabled instance if it is.
import time
import enlighten
manager = enlighten.get_manager()
ticks = manager.counter(total=100, desc='Ticks', unit='ticks')
tocks = manager.counter(total=20, desc='Tocks', unit='tocks')
for num in range(100):
time.sleep(0.1) # Simulate work
print(num)
ticks.update()
if not num % 5:
tocks.update()
manager.stop()
Counters
The Counter class has two output formats, progress bar and counter.
The progress bar format is used when a total is not None and the count is less than the total. If neither of these conditions are met, the counter format is used:
import time
import enlighten
counter = enlighten.Counter(desc='Basic', unit='ticks')
for num in range(100):
time.sleep(0.1) # Simulate work
counter.update()
Additional Examples
basic - Basic progress bar
context manager - Managers and counters as context managers
floats - Support totals and counts that are floats
multicolored - Multicolored progress bars
multiple with logging - Nested progress bars and logging
FTP downloader - Show progress downloading files from FTP
Customization
Enlighten is highly configurable. For information on modifying the output, see the Series and Format sections of the Counter documentation.
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 enlighten-1.11.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98c9eb20e022b6a57f1c8d4f17e16760780b6881e6d658c40f52d21255ea45f3 |
|
MD5 | ef4869a49af7fab0418331a26d7b9ce1 |
|
BLAKE2b-256 | 59a6ec1f9f45fc9ec10c086c1164ba74c68545ed65e988bba467857d07298427 |