Skip to content

Pushing animation frames to the view #343

Answered by jourdain
apcode asked this question in Trame/VTK
Discussion options

You must be logged in to vote

The solution below is just using the async event loop. If you need a tread you need to sync the request with the event loop like we do here

import time
import asyncio

import pyvista as pv

from pyvista.trame.ui import plotter_ui
from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout

pv.OFF_SCREEN = True

server = get_server()
state, ctrl = server.state, server.controller

cyl = pv.Cylinder(resolution=8, direction=(0, 1, 0))

pl = pv.Plotter()
pl.background_color = (0.1, 0.2, 0.4)
pl.add_mesh(cyl, name="cyl")

keep_rotate = True

@ctrl.add_task("on_server_ready")
async def _update(**kwargs):
    await asyncio.sleep(5)
    while keep_rotate:
        cyl.rotate_x(10.0

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jourdain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants