Pre-built Unicode braille spinner animations as raw frame data
Project description
unicode-animations
Python port of gunnargray-dev/unicode-animations.
18 pre-built Unicode braille spinner animations, a ready-to-use live_spinner context manager for CLI apps, and grid utilities for building custom spinners. Zero dependencies — stdlib only.
Install
uv add unicode-animations
Quick start
from unicode_animations import live_spinner
import time
with live_spinner("helix", text="Loading...", color="cyan"):
time.sleep(3)
Usage
Live spinner for CLI apps
LiveSpinner runs animation in a background thread and cleans up automatically:
from unicode_animations import live_spinner
# As a context manager
with live_spinner("dna", text="Downloading...", color="green"):
do_work()
# Manual control
from unicode_animations import LiveSpinner
sp = LiveSpinner("helix", text="Processing...", color="cyan")
sp.start()
# ... do work ...
sp.stop(symbol="✓") # stop with a final symbol
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
name_or_spinner |
str | Spinner |
required | A spinner name or a Spinner instance |
text |
str |
"" |
Status text shown next to the spinner |
color |
str | None |
None |
ANSI color: red, green, yellow, blue, magenta, cyan, white |
stream |
IO[str] | None |
stderr |
Output stream (non-TTY streams get a text-only fallback) |
scale |
int |
1 |
Scale factor (2 or 3) for bigger rendering |
Raw frame data
from unicode_animations import spinners
spinner = spinners["helix"]
print(spinner.frames) # tuple of animation frames
print(spinner.interval) # ms between frames
Custom spinners with the grid API
from unicode_animations import make_grid, grid_to_braille, braille_to_grid
grid = make_grid(4, 2) # 4 rows x 2 cols (one braille char)
grid[0][0] = True
grid[3][1] = True
print(grid_to_braille(grid)) # ⡁
# Decode back to grid
grid = braille_to_grid("⡁")
print(grid[0][0]) # True
Scaling spinners
from unicode_animations import spinners, scale_spinner
big = scale_spinner(spinners["helix"], factor=2) # 2x bigger
print(big.frames[0]) # multi-line braille output
Using in TUI frameworks
LiveSpinner is designed for simple CLI scripts. For TUI frameworks that manage the full screen (Textual, Rich, curses), use the raw frame data instead — it's just tuples of strings and an interval, so it plugs into any rendering system:
Textual:
from textual.app import App, ComposeResult
from textual.widgets import Static
from unicode_animations import spinners
class SpinnerWidget(Static):
def on_mount(self) -> None:
self.spinner = spinners["helix"]
self.frame_idx = 0
self.set_interval(self.spinner.interval / 1000, self.next_frame)
def next_frame(self) -> None:
self.update(self.spinner.frames[self.frame_idx % len(self.spinner.frames)])
self.frame_idx += 1
class MyApp(App):
def compose(self) -> ComposeResult:
yield SpinnerWidget()
MyApp().run()
Rich:
from rich.live import Live
import time
from unicode_animations import spinners
spinner = spinners["dna"]
with Live("", refresh_per_second=1000 / spinner.interval) as live:
for i in range(100):
live.update(spinner.frames[i % len(spinner.frames)])
time.sleep(spinner.interval / 1000)
curses:
import curses
import time
from unicode_animations import spinners
def main(stdscr):
curses.curs_set(0)
spinner = spinners["orbit"]
for i in range(100):
stdscr.addstr(0, 0, spinner.frames[i % len(spinner.frames)])
stdscr.refresh()
time.sleep(spinner.interval / 1000)
curses.wrapper(main)
CLI demo
python -m unicode_animations # cycle through all
python -m unicode_animations helix # preview one
python -m unicode_animations helix --color cyan # with color
python -m unicode_animations helix --scale 2 # bigger
python -m unicode_animations --list # list all names
python -m unicode_animations --list --scale 2 # list with scaled samples
python -m unicode_animations --duration 5 # set preview duration
Available spinners
braille · braillewave · dna · scan · rain · scanline · pulse · snake · sparkle · cascade · columns · orbit · breathe · waverows · checkerboard · helix · fillsweep · diagswipe
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
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 unicode_animations-0.2.2.tar.gz.
File metadata
- Download URL: unicode_animations-0.2.2.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8f78a20af4353be1d4486e212a2b17716485cd58b8fe650c8273b5275a331f6
|
|
| MD5 |
85c9f4368afd4242772d63cf6aaa7269
|
|
| BLAKE2b-256 |
cdefdeecc79b887b15811009a1189f9792222669d788e363b9fb33eeeac39685
|
File details
Details for the file unicode_animations-0.2.2-py3-none-any.whl.
File metadata
- Download URL: unicode_animations-0.2.2-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13eca9351abd5e821f2e9126fd8aa72f64c92697b3fe2d644e8d09f12080bc9e
|
|
| MD5 |
d63898aa359be63d73c64a5b0bf42a38
|
|
| BLAKE2b-256 |
0efc755f2213ceb99b37a53b8098c90df12ee3ed24391c904270b8748191cd50
|