Skip to content

Latest commit

 

History

History
81 lines (52 loc) · 2.57 KB

README.md

File metadata and controls

81 lines (52 loc) · 2.57 KB

CI Documentation Status PyPI version

rendercanvas

One canvas API, multiple backends 🚀

Introduction

See how the two windows above look the same? That's the idea; they also look the same to the code that renders to them. Yet, the GUI systems are very different (Qt vs glfw in this case). Now that's a powerful abstraction!

Purpose

  • Provide a generic canvas API to render to.
  • Provide an event loop for scheduling events and draws.
  • Provide a simple but powerful event system with standardized event objects.
  • Provide various canvas implementations:
    • One that is light and easily installed (glfw).
    • For various GUI libraries (e.g. qt and wx), so visuzalizations can be embedded in a GUI.
    • For specific platforms (e.g. Jupyter, browser).

The main use-case is rendering with wgpu, but rendercanvascan be used by anything that can render based on a window-id or by producing rgba images.

Installation

pip install rendercanvas

To have at least one backend, we recommend:

pip install rendercanvas glfw

Usage

Also see the online documentation and the examples.

# Select either the glfw, qt or jupyter backend
from rendercanvas.auto import RenderCanvas, loop

# Visualizations can be embedded as a widget in a Qt application.
# Supported qt libs are PySide6, PyQt6, PySide2 or PyQt5.
from rendercanvas.pyside6 import QRenderWidget


# Now specify what the canvas should do on a draw
TODO

License

This code is distributed under the 2-clause BSD license.

Developers

  • Clone the repo.
  • Install rendercanvas and developer deps using pip install -e .[dev].
  • Use ruff format to apply autoformatting.
  • Use ruff check to check for linting errors.
  • Optionally, if you install pre-commit hooks with pre-commit install, lint fixes and formatting will be automatically applied on git commit.
  • Use pytest tests to run the tests.