Skip to main content

Lightweight, pretty progress bars for Python CLI apps. No dependencies.

Project description

⚡ flashbar

Lightweight, pretty progress bars for Python CLI apps.

Zero dependencies. Python 3.8+. Just install and go.

flashbar demo

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.

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)

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)

API reference

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

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.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flashbar-1.0.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flashbar-1.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file flashbar-1.0.1.tar.gz.

File metadata

  • Download URL: flashbar-1.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for flashbar-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6484019f54228b310cb73eeaa17fff6aed27dae6e3c290bebaa2f67e9b261044
MD5 31f4c22987b4df046dae35177d917de8
BLAKE2b-256 28d783a47a7e6ff1b0a539d757528ba8d15de98eadf1eb47a8789bfec9287096

See more details on using hashes here.

File details

Details for the file flashbar-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: flashbar-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for flashbar-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41ed1c996cfbe7e07643b075de2d3f95ba19d8d73e1edb4028af2fd09dff302e
MD5 4840f7ffa32ef0c1a4d5bfa0eef79fab
BLAKE2b-256 bc826af92f3d9200c187639014dce99b6b4b7187e421afee43932cdcf0c63028

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page