Skip to main content

โšก flashbar

๐ŸŒ English ยท ็ฎ€ไฝ“ไธญๆ–‡ ยท ะ ัƒััะบะธะน

README: generated with AI

Lightweight progress bars and formatted CLI output for Python 3.8+. No runtime dependencies.

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)

Formatted 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", width=47))

print(rule("Status indicators", width=51))

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.

Pass plain=True to panel(), rule(), or a status helper for ANSI-free ASCII decoration. Nested ANSI sequences in user text are stripped in this mode:

print(success("Tests passed", plain=True))  # [OK] Tests passed
print(rule("Build log", width=32, plain=True))

With the default plain=None, these helpers use styled Unicode only when stdout is an encodable TTY. Pass plain=False to force styling.

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")

Custom fill and empty values must each occupy exactly one terminal cell.

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. Negative steps are rejected. Calling .set() below the total reopens a completed bar and restarts its timer.

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 Positive finite seconds between frames

Methods: .start(), .stop(final_text=None), context manager.

Formatted 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
plain bool or None None Auto-detect output; True = ASCII, False = styled

rule(label="", width=None, color=None, plain=None) -> str

Horizontal divider. Empty label creates an unlabelled line. Its visible width always matches width. With plain=None, output is styled only when sys.stdout is a TTY; pass plain=False to force styling.

Status indicators (return str)

Status helpers use the same plain=None auto-detection. Pass plain=False to force color or plain=True for portable ASCII text.

success("ok")  # โœ“ ok
error("no")    # โœ— no
warn("hmm")    # โš  hmm
info("fyi")    # โ„น fyi

success("ok", plain=True)  # [OK] ok

print_panel(text, title=None, color=None, file=None, **kwargs)

Builds and prints a panel. Non-TTY output is compact by default. Pass plain=True to keep a full ASCII panel or plain=False to force the styled panel.

License

MIT

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.3.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

flashbar-1.3.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flashbar-1.3.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flashbar-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6a70e2d12424775eee1f3080876e3fcbf35e10b8177ee95d203d2a431c61532a
MD5 ea522c94e77f7a639983c0d5510178ab
BLAKE2b-256 26e1420ff8583b5b9a1486211c91b7965299f9b9234d906fe1696b2c584f2f70

See more details on using hashes here.

Provenance

The following attestation bundles were made for flashbar-1.3.0.tar.gz:

Publisher: release.yml on k38f/flashbar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: flashbar-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flashbar-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94ceea408460ba67bd1bdde934abd8c2fdf7fe83698a94f49e8663a9b0947bc9
MD5 58caf75cc78f9a09441537c6721ce696
BLAKE2b-256 2ef593ac842ae1629396444d1ec68037c1dc398b726567fb96f594fa5d5c2269

See more details on using hashes here.

Provenance

The following attestation bundles were made for flashbar-1.3.0-py3-none-any.whl:

Publisher: release.yml on k38f/flashbar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.4.0

2 files

This release

1.3.0 This release

2 files

1.2.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

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