Lightweight, pretty progress bars for Python CLI apps. No dependencies.
Project description
โก flashbar
๐ English ยท ็ฎไฝไธญๆ
Parts of this README were translated and edited with AI.
A progress bar โ and now pretty CLI output โ you can read end-to-end in one coffee break.
One package. Tiny. No magic. No dependencies. Python 3.8+.
Install
pip install flashbar
Quick start
from flashbar import track
import time
for item in track(range(100), label="Downloading"):
time.sleep(0.02)
That's it. One import, one line.
What's new in 1.2
- Pretty output module โ
panel(),rule(), plussuccess(),error(),warn(),info()indicators. Wrap any text in styled boxes without pulling in rich. - All 1.1 improvements: smooth bar rendering, TTY detection, throttled redraws, type hints, better short-task ETA.
Pretty output
Build styled CLI output with a few small functions:
from flashbar import panel, rule, success, error, warn, info
print(panel("Build complete\n42 files compiled in 1.2s",
title="Status", color="green"))
print(rule("Status indicators"))
print(success("Tests passed"))
print(error("Build failed"))
print(warn("Deprecated API"))
print(info("Update available"))
Output:
โญโ Status โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Build complete โ
โ 42 files compiled in 1.2s โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโโโโโโโโโโโโโโโ Status indicators โโโโโโโโโโโโโโโโ
โ Tests passed
โ Build failed
โ Deprecated API
โน Update available
Panel styles
Five border styles available:
panel("body", style="rounded") # โญ โฎ โฐ โฏ (default)
panel("body", style="square") # โ โ โ โ
panel("body", style="double") # โ โ โ โ
panel("body", style="heavy") # โ โ โ โ
panel("body", style="ascii") # + + + +
Auto-fits to content, or pass width=N for a fixed size. Custom color (named or hex) and padding are supported.
Rule
Horizontal divider, optionally with a centered label:
print(rule()) # full-width line
print(rule("Section 1")) # centered label
print(rule("Done", color="green")) # colored
Print helper
If you don't want to call print() yourself:
from flashbar import print_panel
print_panel("Connection failed", title="Error", color="red")
When output isn't a TTY (logs, CI), styling strips automatically โ your log files stay clean.
Progress bar
from flashbar import Bar
bar = Bar(100, label="Processing", theme="green")
for i in range(100):
bar.update()
# or jump to a specific value
bar = Bar(100)
bar.set(50) # jump to 50%
bar.set(100) # done
With context manager
Automatically completes the bar on exit, even on exceptions:
with Bar(100, theme="retro", label="Building") as bar:
for i in range(100):
do_work()
bar.update()
ETA and speed
# ETA is on by default
bar = Bar(1000, label="Training", show_eta=True)
# show items/sec too
bar = Bar(1000, label="Training", show_speed=True)
Smooth rendering
Sub-character rendering makes bars look much more fluid. It's auto-enabled when the fill character is โ, and you can toggle it explicitly:
# always smooth
Bar(100, smooth=True)
# always classic
Bar(100, smooth=False)
Spinner
For tasks where you don't know the total:
from flashbar import Spinner
with Spinner("Loading data...", style="dots"):
load_big_file()
# manual control
sp = Spinner("Thinking...", style="circle", color="magenta")
sp.start()
result = heavy_computation()
sp.stop("Done!")
Themes
See the demo GIF above to see each theme in action with real colors.
from flashbar import Bar
for name in ["default", "green", "red", "retro", "minimal", "slim", "dots", "arrow"]:
bar = Bar(30, theme=name, label=f"{name:8s}")
for _ in range(30):
bar.update()
| Theme | Look |
|---|---|
default |
โโโโโโโโโโ ๐ต blue |
green |
โโโโโโโโโโ ๐ข green |
red |
โโโโโโโโโโ ๐ด red |
retro |
#####..... ๐ก yellow |
minimal |
โโโโโ โช white |
slim |
โโโโโโบโบโบโบโบ ๐ต cyan |
dots |
โโโโโโโโโโ ๐ฃ magenta |
arrow |
โธโธโธโธโธโนโนโนโนโน ๐ต blue |
Spinner styles
| Style | Frames |
|---|---|
dots |
โ โ โ น โ ธ โ ผ โ ด โ ฆ โ ง |
line |
- \ | / |
circle |
โ โ โ โ |
bounce |
โ โ โ โ |
arrows |
โ โ โ โ |
grow |
โ โ โ โ โ โ โ โ |
moon |
๐๐๐๐๐๐๐๐ |
Custom colors
# named
Bar(100, color="cyan", label="Cyan bar")
# any hex color
Bar(100, color="#FF5733", label="Orange bar")
Bar(100, color="#00FF99", label="Mint bar")
Custom characters
Bar(100, fill="โ", empty="โ")
Bar(100, fill="=", empty="-")
Bar(100, fill="โ", empty="โ", color="#FF69B4")
Generators and iterators
track() works with anything that has len(). For generators, pass total=:
def my_generator():
for i in range(1000):
yield i
for item in track(my_generator(), total=1000, label="Generating"):
process(item)
Behavior in non-TTY environments
When output is piped to a file or running in CI, flashbar detects that automatically and stays quiet โ only the final line is printed, without any escape codes:
python myscript.py 2> log.txt # log.txt stays clean
python myscript.py 2>&1 | tee # no garbled output
API reference
Progress
Bar(total, **options)
| Param | Type | Default | Description |
|---|---|---|---|
total |
int | required | Number of steps |
width |
int | 40 |
Bar width in characters |
theme |
str | "default" |
Theme name |
label |
str | "" |
Text before the bar |
color |
str | None |
Override color (name or hex) |
fill |
str | None |
Override fill character |
empty |
str | None |
Override empty character |
show_eta |
bool | True |
Show estimated time remaining |
show_speed |
bool | False |
Show items/sec |
smooth |
bool | None |
Sub-character rendering. None = auto |
Methods: .update(step=1), .set(value), context manager.
track(iterable, **options)
Same options as Bar, plus total= for iterables without len().
Spinner(label, **options)
| Param | Type | Default | Description |
|---|---|---|---|
label |
str | "" |
Text next to spinner |
style |
str | "dots" |
Spinner animation style |
color |
str | "cyan" |
Color (name or hex) |
speed |
float | 0.08 |
Seconds between frames |
Methods: .start(), .stop(final_text=None), context manager.
Pretty output
panel(text, **options) -> str
| Param | Type | Default | Description |
|---|---|---|---|
text |
str | required | Body content (may contain newlines) |
title |
str | None |
Optional title in the top border |
color |
str | None |
Border color (name or hex) |
width |
int | None |
Total width. None = auto-fit content |
style |
str | "rounded" |
rounded, square, double, heavy, ascii |
padding |
int | 1 |
Horizontal padding inside the box |
rule(label="", width=None, color=None) -> str
Horizontal divider. Empty label for plain line.
Status indicators (return str)
success("ok") # โ ok
error("no") # โ no
warn("hmm") # โ hmm
info("fyi") # โน fyi
print_panel(text, title=None, color=None, file=None, **kwargs)
Convenience: builds and prints a panel. Strips styling automatically when output isn't a TTY.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flashbar-1.2.0.tar.gz.
File metadata
- Download URL: flashbar-1.2.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81631420c0cbbf6abb525e055b3b7db5421d430264a3b127bdc4bd01a4ad117e
|
|
| MD5 |
ac2c8c28b4f9d647ce33f4644367e6cd
|
|
| BLAKE2b-256 |
ce74292b5815d12411c2d3a04ec0f6c094886893a26142596de281e16b99ba77
|
File details
Details for the file flashbar-1.2.0-py3-none-any.whl.
File metadata
- Download URL: flashbar-1.2.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48b905b24e5c8b1024b0dac71da58e56872394356b6ff012813d940a91cfeada
|
|
| MD5 |
54bcd004a6bac8866339c12792e087e1
|
|
| BLAKE2b-256 |
d8bd3f7052dc869d9c7b9d193f93bd75ef9c654265b4d05a0ada1605543944d5
|