Skip to main content

Cross-platform Python library providing Lottie animation support for Qt applications

Project description

Qt Lottie

PyPI version Python versions License: MIT

Cross-platform Python library providing Lottie animation support for Qt applications, compatible with both PySide6 and PyQt6.

Features

  • QML Component: Feature-rich LottieAnimation component for QML applications
  • Python API: Programmatic control of animations from Python
  • Cross-binding compatibility: Works with both PySide6 and PyQt6
  • Performance optimized: Uses RLottie backend with Qt-style caching
  • Zero-configuration: Simple pip installation

Installation

# Auto-detect Qt binding
pip install qt-lottie

# With specific Qt binding
pip install qt-lottie[pyside6]
pip install qt-lottie[pyqt6]

Quick Start

QML Usage

import QtQuick 2.15
import QtQuick.Window 2.15
import QtLottie 1.0

Window {
    width: 640
    height: 480
    visible: true
    
    LottieAnimation {
        anchors.centerIn: parent
        width: 200
        height: 200
        source: "path/to/animation.json"
        autoPlay: true
        loops: -1  // Infinite loops
        
        onFinished: console.log("Animation finished")
    }
}

Python Usage

import sys
from PySide6.QtWidgets import QApplication
from PySide6.QtQml import QQmlApplicationEngine
import qtlottie

# Initialize QML types
qtlottie.init_qml()

app = QApplication(sys.argv)
engine = QQmlApplicationEngine()

# Load QML that uses LottieAnimation
engine.load("main.qml")

sys.exit(app.exec())

API Reference

LottieAnimation Properties

Source & Loading

  • source: url - Animation file path/URL
  • status: int - Loading status (Null, Loading, Ready, Error)
  • asynchronous: bool - Async loading (default: true)
  • cacheMode: int - CacheNone, CacheLoop, CacheAll (default: CacheNone)

Playback Control

  • playing: bool - Play state (default: false)
  • autoPlay: bool - Auto-start (default: false)
  • playbackRate: real - Speed multiplier (default: 1.0)
  • loops: int - Loop count (-1 = infinite)
  • direction: int - Forward, Reverse, Alternate

Timing & Position

  • position: real - Current time in seconds
  • duration: real - Total duration (read-only)
  • progress: real - Progress 0.0-1.0 (read-only)
  • currentFrame: int - Current frame (read-only)

Visual Properties

  • tintColor: color - Color overlay
  • fillMode: int - Stretch, PreserveAspectFit, PreserveAspectCrop
  • smooth: bool - Antialiasing (default: true)

Methods

  • play() - Start animation
  • pause() - Pause animation
  • stop() - Stop and reset animation
  • toggle() - Toggle play/pause
  • seek(position) - Seek to time position
  • seekToFrame(frame) - Seek to frame number
  • seekToMarker(name) - Seek to named marker

Signals

  • started() - Animation started
  • stopped() - Animation stopped
  • finished() - Animation finished
  • positionChanged(real) - Position changed
  • frameChanged(int) - Frame changed
  • markerReached(string) - Marker reached
  • error(string) - Error occurred

Performance

The library is designed for optimal performance with Qt-style size-based frame caching.

Cache Modes

  • CacheNone: Render frames on demand (default, lowest memory)
  • CacheLoop: Cache one complete animation loop
  • CacheAll: Cache entire animation (best performance for small animations)

Requirements

  • Python 3.8+
  • PySide6 or PyQt6
  • rlottie-python
  • Pillow (for image processing)

License

MIT License - see LICENSE file for details.

Development

Setup

# Clone repository
git clone https://gitlab.com/acemetrics-oss/qt-lottie.git
cd qt-lottie

# Install in development mode
pip install -e ".[dev,pyside6,pyqt6]"

Building

# Build package
python -m build

# Install from wheel
pip install dist/*.whl

# Test basic functionality
python -c "import qtlottie; print('✓ Import successful')"

Testing

# Test examples
cd examples/pyside6
python main.py

cd ../pyqt6  
python main.py

Contributing

Contributions welcome! Please see our GitLab repository for guidelines.

Links

Support

  • Issues: Report bugs and request features on GitLab Issues
  • Documentation: Full API reference available in the repository
  • Examples: Working examples for both PySide6 and PyQt6 included

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

qt_lottie-0.1.2.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

qt_lottie-0.1.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file qt_lottie-0.1.2.tar.gz.

File metadata

  • Download URL: qt_lottie-0.1.2.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for qt_lottie-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1e69eae5e3bd469488136413092002dfd697f9720a2f230bc175b68a3d3a4525
MD5 8a610f57b8d78bebd099e7afe0e5964e
BLAKE2b-256 1e4f22e1cb516532d2c5317e9de7fc4f4b9e0d062bdaebca5e5b5231f17359b9

See more details on using hashes here.

File details

Details for the file qt_lottie-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: qt_lottie-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for qt_lottie-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a79b9fc699f18ca17eab8b57374559c8a598b9afcb8672b46fca23f4dd3dbf79
MD5 640ac497673830074b7c3c20be056c2b
BLAKE2b-256 eb73df14088c453396131e35e93989054f36b5c186bb5a2eaa4efe27b0f30c48

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