Skip to main content

Gradio PyVista Viewer

Project description

trame-gradio-component

A Gradio custom component that embeds an interactive PyVista plotter in any Gradio app.

Installation

Clone the repository, then install the package:

pip install gradio_pyvistaplotter/

Quick Start

The following minimal example renders an interactive 3D sphere:

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:

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?

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

gradio_pyvistaplotter-0.1.0.tar.gz (322.3 kB view details)

Uploaded Source

Built Distribution

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

gradio_pyvistaplotter-0.1.0-py3-none-any.whl (264.9 kB view details)

Uploaded Python 3

File details

Details for the file gradio_pyvistaplotter-0.1.0.tar.gz.

File metadata

  • Download URL: gradio_pyvistaplotter-0.1.0.tar.gz
  • Upload date:
  • Size: 322.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gradio_pyvistaplotter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9afcda2330ce2125ecf28fc3dad9fac4463563c09aa67bf94ef5818f75eda30f
MD5 0623f0ec60c87d2b025934e55dcd9bc7
BLAKE2b-256 4be7c05988bdc27ebf5e7c432c465a4f9d22ddf91bc621fc26cce5d649d3bb99

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_pyvistaplotter-0.1.0.tar.gz:

Publisher: publish.yml on Louis-Pujol/gradio-pyvistaplotter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gradio_pyvistaplotter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_pyvistaplotter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb9ba8c31e286f8bf40d4248a8cf842c3ddc50b447eb014dd5d76c4018e21ad4
MD5 5c47351f5c19c0e77e3a70d8fa201806
BLAKE2b-256 e46418b493a867749a1b01113b6913e83476c1fadd1622a72b8b1f1c8c5ec306

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradio_pyvistaplotter-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Louis-Pujol/gradio-pyvistaplotter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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