A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive styling system with predefined spinners, bars, and themes, plus demonstration tools for previewing all available styles. Provides both ready-to-use visual elements and the foundation for custom animation creation.
Interactive demonstration functions that display animated previews of all available styles, helping users choose and test visual elements.
def showtime(show=Show.SPINNERS, *, fps=None, length=None, pattern=None):
"""
Display animated demos of all available styles.
Parameters:
- show (Show): Type of styles to display (Show.SPINNERS, Show.BARS, Show.THEMES)
- fps (Optional[float]): Frames per second for animation
- length (Optional[int]): Bar length for display
- pattern (Optional[Pattern]): Regex pattern to filter displayed items
"""
def show_spinners(*, fps=None, length=None, pattern=None):
"""
Show all available spinner animations.
Parameters:
- fps (Optional[float]): Animation speed in frames per second
- length (Optional[int]): Bar length for spinner display
- pattern (Optional[Pattern]): Filter spinners by name pattern
"""
def show_bars(*, fps=None, length=None, pattern=None):
"""
Show all available bar styles.
Parameters:
- fps (Optional[float]): Animation speed for bars
- length (Optional[int]): Bar length for display
- pattern (Optional[Pattern]): Filter bars by name pattern
"""
def show_themes(*, fps=None, length=None, pattern=None):
"""
Show all available themes.
Parameters:
- fps (Optional[float]): Animation speed for theme preview
- length (Optional[int]): Bar length for display
- pattern (Optional[Pattern]): Filter themes by name pattern
"""from alive_progress.styles import showtime, show_spinners, show_bars, show_themes, Show
import re
# Show all spinners
show_spinners()
# Show all bars
show_bars()
# Show all themes
show_themes()
# Show all styles at once
showtime(Show.SPINNERS)
showtime(Show.BARS)
showtime(Show.THEMES)
# Custom animation speed and bar length
show_spinners(fps=10, length=30)
# Filter by pattern
show_spinners(pattern=re.compile(r'.*dot.*'))
show_bars(pattern=re.compile(r'solid.*'))Built-in collections of predefined visual elements that can be used directly in alive_bar configuration.
SPINNERS: Dict[str, SpinnerFactory]
"""Dictionary of all available spinner styles."""
BARS: Dict[str, BarFactory]
"""Dictionary of all available bar styles."""
THEMES: Dict[str, Dict[str, Any]]
"""Dictionary of all available themes (combinations of spinner, bar, and unknown styles)."""Common spinner styles include:
'classic': Traditional rotating characters'dots': Pulsing dots animation'filling': Filling container effect'scrolling': Scrolling characters'bouncing': Bouncing ball effect'sequential': Sequential character changes'alongside': Multiple elements together'delayed': Timing-delayed animationsCommon bar styles include:
'classic': Traditional solid progress bar'smooth': Smooth gradient transitions'filling': Container filling effect'blocks': Block-based progress'underflows': Shows negative progress'overflows': Shows excess progressPredefined themes combining spinner, bar, and unknown styles:
'smooth': Modern smooth animations'classic': Traditional terminal appearance'ascii': ASCII-only characters for compatibilityfrom alive_progress import alive_bar
from alive_progress.styles import SPINNERS, BARS, THEMES
# Use specific spinner and bar
with alive_bar(1000, spinner='dots', bar='smooth') as bar:
pass
# Use predefined theme
with alive_bar(1000, theme='classic') as bar:
pass
# Inspect available options
print("Available spinners:", list(SPINNERS.keys()))
print("Available bars:", list(BARS.keys()))
print("Available themes:", list(THEMES.keys()))
# Mix and match
with alive_bar(1000,
spinner='bouncing',
bar='blocks',
unknown='scrolling') as bar:
passEnumeration for specifying which type of styles to display in showtime demonstrations.
class Show(Enum):
"""Enumeration for showtime display types."""
SPINNERS = "SPINNERS"
BARS = "BARS"
THEMES = "THEMES"from alive_progress.styles import showtime, Show
# Show specific style types
showtime(Show.SPINNERS)
showtime(Show.BARS)
showtime(Show.THEMES)
# With additional parameters
showtime(Show.SPINNERS, fps=15, length=25)Using custom styles with the predefined collections and style system.
# Direct style names
with alive_bar(1000, spinner='dots', bar='smooth') as bar:
pass
# Using SPINNERS/BARS dictionaries
from alive_progress.styles import SPINNERS, BARS
dot_spinner = SPINNERS['dots']
smooth_bar = BARS['smooth']
with alive_bar(1000, spinner=dot_spinner, bar=smooth_bar) as bar:
passfrom alive_progress.styles import THEMES
# Apply theme manually
theme_config = THEMES['classic']
with alive_bar(1000, **theme_config) as bar:
pass
# Override theme elements
with alive_bar(1000, theme='smooth', spinner='dots') as bar:
pass # Uses smooth theme but with dots spinnerimport random
from alive_progress.styles import SPINNERS, BARS
# Random style selection
spinner_name = random.choice(list(SPINNERS.keys()))
bar_name = random.choice(list(BARS.keys()))
with alive_bar(1000, spinner=spinner_name, bar=bar_name) as bar:
passimport os
from alive_progress.styles import THEMES
# ASCII mode for restricted environments
if os.getenv('TERM') == 'dumb':
theme = 'ascii'
else:
theme = 'smooth'
with alive_bar(1000, theme=theme) as bar:
pass# Define custom theme
my_theme = {
'spinner': 'bouncing',
'bar': 'blocks',
'unknown': 'scrolling',
'length': 50,
'dual_line': True
}
# Use custom theme
with alive_bar(1000, **my_theme) as bar:
pass
# Or extend existing theme
from alive_progress.styles import THEMES
extended_theme = {**THEMES['classic'], 'length': 60, 'dual_line': True}
with alive_bar(1000, **extended_theme) as bar:
passfrom alive_progress.styles import show_spinners, SPINNERS
import time
# Preview all spinners
show_spinners()
# Test specific spinner in actual progress bar
for spinner_name in ['dots', 'bouncing', 'scrolling']:
print(f"Testing {spinner_name} spinner:")
with alive_bar(50, spinner=spinner_name, title=f'{spinner_name} test') as bar:
for i in range(50):
time.sleep(0.1)
bar()
print()# For high throughput, use simpler styles
with alive_bar(1000000,
spinner=None, # Disable spinner for maximum performance
refresh_secs=0.1) as bar:
for i in range(1000000):
fast_operation()
bar()
# For visual appeal with moderate performance
with alive_bar(10000,
theme='smooth',
refresh_secs=0.05) as bar:
for i in range(10000):
moderate_operation()
bar()Install with Tessl CLI
npx tessl i tessl/pypi-alive-progress