⏳ console-animation
A lightweight and flexible Python decorator to show a console animation (loading animation) while a function is running. Useful for long-running CLI tasks, data processing, I/O, or just making your tools feel more alive.
🔧 Features
- Add a console animation with a single line
- Optional start, end, and error messages
- Customizable animation style and speed
- Gracefully handles exceptions
- Works with or without decorator arguments
- Clean terminal output (hides cursor during spin)
📦 Installation
# pip install
pip install console_animation
# or
# Clone the repo
git clone https://github.com/KoushikEng/console_animation.git
cd console_animation
# Install locally
pip install .
You can also install it in editable mode during development:
pip install -e .
🚀 Usage
✅ Basic animation (no args)
from console_animation import animate
@animate
def task():
import time
time.sleep(3)
This will show a rotating animation while task() runs.
⚙️ With Custom Messages
@animate(start="Processing...", loaded="✅ Task complete!", error="❌ Something broke.")
def do_work():
time.sleep(5)
start– message shown before animationloadedorend– message shown after successful runerror– message shown if exception occurs
🎯 Custom animation and Speed
@animate(spinner="⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓", interval=0.05)
def fancy_task():
time.sleep(3)
spinner: any iterable of charactersinterval: time (in seconds) between frames
❗ Error Handling
If error is not provided:
- The animation will stop
- Cursor will be restored
- The original exception is raised as-is
If error is set:
- It will be printed
- Full traceback is also printed for debugging
🧪 Example Script
from console_animation import animate
import time
@animate(start="Crunching numbers...", loaded="✅ Done!", error="🔥 Failed.")
def math_task():
time.sleep(3)
@animate
def quick_task():
time.sleep(1)
@animate(start="Breaking...", error="Oops.")
def will_fail():
raise RuntimeError("Intentional failure.")
math_task()
quick_task()
will_fail()
🤝 Contributing
Contributions are welcome and appreciated!
If you want to:
- Add features (like async support, presets, color, etc.)
- Improve performance or compatibility
- Fix bugs
- Write tests or improve docs
Please feel free to:
- Fork the repo
- Create a new branch (
feature/your-feature) - Commit your changes
- Push and open a PR
Issues and suggestions are also welcome in the Issues tab.
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.
🙌 Credits
Built with frustration from boring terminal waits and love for clean CLI UX.
🛠️ To Do (Open for PRs)
- Async function support (
async def) - Color support (via
colorama) - Predefined animation styles
- Timeout decorator option
- PyPI upload
Made by Koushik 🔥
Metadata
Release files for console-animation 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| console_animation-0.2.7.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| console_animation-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / console_animation-0.2.7.tar.gz
| Download URL | console_animation-0.2.7.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd4c4a14f27068ce169ecf67d98b6aedcbe14c371b1e6d5ea05e0a18ac36888e
|
|
BLAKE2b-256 checksum How to use checksums |
c6b64bcbf09fdc92ca143e3295c113e9f726a0682fb91400d8635d5c2dc6676d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / console_animation-0.2.7-py3-none-any.whl
| Download URL | console_animation-0.2.7-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e693e1e363a0e6ab99e6a47ee7f4a204383c62cbdc48a527f515e4f37f4f01fc
|
|
BLAKE2b-256 checksum How to use checksums |
dc17cfb183341c6713a8e2655d71210d57a21e6471e8ae69a842a24b3efa98ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency log