Enlighten Progress Bar is a console progress bar library for Python
—
Status bar functionality for displaying text-based status updates with formatting and justification options. Status bars provide a way to show textual information that updates in place, complementing progress bars for comprehensive user feedback.
Text-based status displays with formatting, justification, and dynamic field support.
class StatusBar:
def __init__(self, enabled=True, color=None, fields=None, fill=' ',
justify=Justify.LEFT, leave=True, min_delta=0.1,
status_format='{message}', manager=None, **kwargs):
"""
Status bar for text-based status updates.
Parameters:
- enabled: Status bar enabled state (default: True)
- color: Status bar color (str or RGB tuple)
- fields: Additional fields for formatting (dict)
- fill: Fill character for justification (default: ' ')
- justify: Text justification (Justify.LEFT/CENTER/RIGHT)
- leave: Leave status visible after closing (default: True)
- min_delta: Minimum time between refreshes in seconds (default: 0.1)
- status_format: Format string for status display
- manager: Manager instance (auto-created if None)
- **kwargs: Additional configuration options
"""
def update(self, *args, **kwargs):
"""
Update status bar with new content.
Parameters:
- *args: Direct status text (joined with spaces)
- **kwargs: Field values for formatted status
When args are provided, they are converted to strings and joined.
When args are empty, status_format is used with kwargs as field values.
"""
def close(self, clear=False):
"""
Close the status bar and clean up display.
Parameters:
- clear: Remove status bar from display (default: False)
"""
def format(self, width=None, elapsed=None):
"""
Format status bar for display.
Parameters:
- width: Width in columns to make status bar
- elapsed: Time since started. Automatically determined if None
Returns:
str: Formatted status bar
"""
def refresh(self, flush=True, elapsed=None):
"""
Refresh status bar display with current values.
Parameters:
- flush: Flush output streams (default: True)
- elapsed: Override elapsed time calculation
"""
def clear(self, flush=True):
"""
Clear status bar display.
Parameters:
- flush: Flush output streams (default: True)
"""
def reset(self):
"""Reset status bar to its initial state."""
def __enter__(self):
"""Context manager entry. Returns self."""
def __exit__(self, *args):
"""Context manager exit. Calls close()."""
def __call__(self, iterable):
"""
Iterate over iterable, updating status bar for each item.
Parameters:
- iterable: Iterable to process
Returns:
Generator yielding items from iterable
"""
@property
def elapsed(self):
"""Elapsed time since status bar creation."""import enlighten
import time
# Create a status bar
status = enlighten.StatusBar()
# Update with direct text
status.update('Starting process...')
time.sleep(1)
status.update('Loading configuration...')
time.sleep(1)
status.update('Processing data...')
time.sleep(2)
status.update('Complete!')
status.close()import enlighten
# Status bar with multiple text arguments
status = enlighten.StatusBar()
# Arguments are joined with spaces
status.update('Status:', 'Processing', 'file', 'data.txt')
# Displays: "Status: Processing file data.txt"
status.update('Error code:', 404, 'Not found')
# Displays: "Error code: 404 Not found"
status.close()import enlighten
import time
# Status bar with custom format
status = enlighten.StatusBar(
status_format='Stage: {stage} | Progress: {progress}% | Time: {elapsed}'
)
# Update using format fields
for i in range(5):
status.update(
stage=f'Phase {i+1}',
progress=i * 20
)
time.sleep(1)
status.close()import enlighten
# Status bar with color and justification
status = enlighten.StatusBar(
color='green',
justify=enlighten.Justify.CENTER,
fill='-'
)
status.update('Centered status with green color')
time.sleep(2)
status.close()import enlighten
import time
# Create manager for coordinated display
manager = enlighten.get_manager()
# Create progress bar and status bar
pbar = manager.counter(total=100, desc='Processing', unit='items')
status = manager.status_bar()
# Update both progress and status
for i in range(100):
# Update progress
pbar.update()
# Update status with current operation
if i < 25:
status.update('Initializing...')
elif i < 50:
status.update('Loading data...')
elif i < 75:
status.update('Processing...')
else:
status.update('Finalizing...')
time.sleep(0.1)
# Final status
status.update('Complete!')
manager.stop()import enlighten
import time
import random
# Status with dynamic fields
status = enlighten.StatusBar(
status_format='Server: {server} | Requests: {requests} | Errors: {errors} | Uptime: {elapsed}'
)
# Simulate server monitoring
requests = 0
errors = 0
for i in range(20):
requests += random.randint(5, 15)
if random.random() < 0.1: # 10% chance of error
errors += 1
status.update(
server='web-01',
requests=requests,
errors=errors
)
time.sleep(0.5)
status.close()import enlighten
# Status bar with additional custom fields
status = enlighten.StatusBar(
fields={'app': 'MyApp', 'version': '1.0'},
status_format='{app} v{version} | {stage} | Elapsed: {elapsed}'
)
# Update with stage information
for stage in ['Init', 'Load', 'Process', 'Save', 'Done']:
status.update(stage=stage)
time.sleep(1)
status.close()Install with Tessl CLI
npx tessl i tessl/pypi-enlighten