Metadata-Version: 2.4
Name: gradio-pyvistaplotter
Version: 0.1.0
Summary: Gradio PyVista Viewer
Project-URL: repository, https://github.com/Louis-Pujol/gradio-pyvistaplotter
Project-URL: space, https://huggingface.co/spaces/Louis-Pujol/gradio-pyvistaplotter
Author: Louis Pujol
License-Expression: MIT
License-File: LICENSE
Keywords: gradio-custom-component,gradio-template-HTML
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.10
Requires-Dist: gradio<7.0,>=6.0
Requires-Dist: pyvista[jupyter]
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pyvista[offscreen]; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# trame-gradio-component

A [Gradio](https://www.gradio.app/) custom component that embeds an interactive [PyVista](https://pyvista.org/) plotter in any Gradio app.

## Installation

Clone the repository, then install the package:

```bash
pip install gradio_pyvistaplotter/
```

## Quick Start

The following minimal example renders an interactive 3D sphere:

```python
import pyvista as pv
import gradio as gr
from gradio_pyvistaplotter import PyvistaPlotter

plotter = pv.Plotter()
plotter.add_mesh(pv.Sphere(), show_edges=True, color="gold")

with gr.Blocks() as demo:
    gr.Markdown("Gradio app with a PyVista plotter")
    viewer = PyvistaPlotter(value=plotter)

demo.launch()
```

A more complete example with a mesh loader is available in `gradio_pyvistaplotter/demo/app.py`.

## Known Issues

### Linux – Ctrl+C does not stop the application

When using `PyvistaPlotter` with the standard `gr.Blocks.launch()` method, the application cannot be interrupted from the terminal via `Ctrl+C`. As a workaround, this package provides a custom `launch()` function that wraps `gr.Blocks.launch()` with proper signal handling:

```python
import pyvista as pv
import gradio as gr
from gradio_pyvistaplotter import PyvistaPlotter, launch

plotter = pv.Plotter()
plotter.add_mesh(pv.Sphere(), show_edges=True, color="gold")

with gr.Blocks() as demo:
    gr.Markdown("Gradio app with a PyVista plotter")
    viewer = PyvistaPlotter(value=plotter)

launch(demo)  # custom launch with proper signal handling
```

## Issues / TODO

- [ ] Currently, two files are written to the tmp directory on each render: `static_viewer.html` and `scene_<id>.vtksz`. Investigate whether the HTML can be generated and passed as an in-memory string instead of a file on disk.
- [ ] `static_viewer.html` is currently bundled with this package — should it be imported directly from `trame` instead?
