Skip to main content

A customizable loading tool

Project description

enimation

enimation is a customizable loading tool for Python projects that allows users to implement various loading animations with extensive customization options. This package enhances user experience during data processing, API calls, or any time-consuming tasks by providing visual feedback.

Features

  • Customizable Loading Animations: Choose from multiple loading animations, or define your own.
  • Duration Control: Specify the update interval for the loading animation.
  • Decorator Support: Easily add loading animations to any function with a simple decorator.

Installation

You can install the package using pip:

pip install enimation

Or if you are developing locally, you can install it in editable mode:

pip install -e .

Basic Usage

To get started with the loading tool, follow these simple steps:

  1. Import the CustomLoading Class

First, import the CustomLoading class from the package:

from enimation import CustomLoading
  1. Create an Instance of CustomLoading

Create an instance of the CustomLoading class, optionally providing a custom animation function and interval:

loader = CustomLoading(interval=0.1)  # 0.1 seconds update interval
  1. Start the Loading Animation

Call the start() method to begin the loading animation in a separate thread:

loader.start()
  1. Stop the Loading Animation

When the task is completed, call the stop() method to stop the animation:

loader.stop()

Example

Here’s a simple example of using CustomLoading:

import time
from enimation import CustomLoading

def long_running_task():
    time.sleep(5)  # Simulate a long-running task

loader = CustomLoading()
loader.start()
long_running_task()
loader.stop()

Advanced Usage

Custom Animations

You can create your own custom loading animations by defining a function that updates the loading display. For example:

def my_custom_animation():
    frames = ['🌟', '✨', '🌈', '💫']
    while not loader.stop_event.is_set():
        for frame in frames:
            print(f'\rLoading {frame}', end='', flush=True)
            time.sleep(0.5)

loader = CustomLoading(animation_function=my_custom_animation, interval=0.5)
loader.start()
long_running_task()
loader.stop()

Using the Loading Decorator

The loading decorator can be used to automatically add loading animations to your functions. Here's how to use it:

from enimation import loading

@loading()  # Use default loading animation
def long_running_task():
    time.sleep(5)  # Simulate a long-running task

long_running_task()

Customizing the Decorator

You can also pass a custom CustomLoading instance to the decorator:

custom_loader = CustomLoading(animation_function=my_custom_animation)

@loading(custom_loading_instance=custom_loader)
def another_long_running_task():
    time.sleep(10)  # Simulate another long-running task

another_long_running_task()

Integration with Asynchronous Tasks

You can run the loading animation in a separate thread alongside your main tasks. For example:

import threading

def long_running_task():
    time.sleep(10)

loader = CustomLoading()
threading.Thread(target=long_running_task).start()
loader.start()
loader.stop()

Contributing

If you'd like to contribute to enimation, please fork the repository and submit a pull request. We welcome contributions of all kinds, including bug fixes, documentation improvements, and new features.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any inquiries or suggestions, feel free to reach out to:

hasan: hasanfq818@gmail.com

GitHub: here

enimation

An animation function for python to higly customize you code with bueatyfull animation

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

enimation-0.1.4.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

enimation-0.1.4-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file enimation-0.1.4.tar.gz.

File metadata

  • Download URL: enimation-0.1.4.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for enimation-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8ab94c5a26df4ff43f3aab42db9e78353c7b0773d8b09914c7d3ce905ad4af52
MD5 6029d6533d844b18761db75a3d41a027
BLAKE2b-256 19a706ea0557adefc9fcc9fedb608765ad9fa3a019475af098c3a4cea43b51f7

See more details on using hashes here.

File details

Details for the file enimation-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: enimation-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for enimation-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9788a0343bfec4fdd87473d1190ec8e0216269bb42326e9c2b00586332e18234
MD5 bfb23d67722914126843e52025d90a68
BLAKE2b-256 1a5f6e0179f45f9d90cc303850a246b68fec6fcd11edef22d2f82d950c758525

See more details on using hashes here.

Supported by

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