Controlling UI elements in callback functions #634
Answered
by
jourdain
NimaGhorab
asked this question in
General
-
Hello guys. from trame.app import get_server
server = get_server(client_type = "vue2")
state, ctrl = server.state, server.controller
import paraview_setup
import os
from dotenv import load_dotenv
load_dotenv()
view, surface, contours = paraview_setup.open_pvd_file(os.environ["PVD_FILE_PATH"])
from trame.widgets import vuetify, paraview
from trame.ui.vuetify import SinglePageWithDrawerLayout
import paraview.simple as pvs
server.state.timestep_text= str(pvs.GetAnimationScene().StartTime)
def play_backward():
animation_scene = pvs.GetAnimationScene()
animation_scene.UpdateAnimationUsingDataTimeSteps()
if animation_scene.TimeKeeper.Time > animation_scene.StartTime:
animation_scene.Reverse()
server.state.timesteps = server.state.timestep_text = str(animation_scene.TimeKeeper.Time)
server.controller.view_update()
def play_forward():
animation_scene = pvs.GetAnimationScene()
animation_scene.UpdateAnimationUsingDataTimeSteps()
if animation_scene.TimeKeeper.Time < animation_scene.EndTime:
animation_scene.Play()
server.state.timesteps = server.state.timestep_text = str(animation_scene.TimeKeeper.Time)
server.controller.view_update()
with SinglePageWithDrawerLayout(server) as layout:
layout.icon.click = server.controller.view_reset_camera
layout.title.set_text("OpenLB Visualizer")
with layout.toolbar as tb:
tb.dense = True
tb.clipped_right = True
with layout.drawer as drawer:
drawer.width = 325
drawer.right = True
vuetify.VSpacer(style="height: 20px;")
with vuetify.VBtn(icon=True, click=play_backward, style="transform: rotate(180deg);"):
vuetify.VIcon("mdi-play")
vuetify.VChip("{{ timestep_text }}")
with vuetify.VBtn(icon=True, click=play_forward):
vuetify.VIcon("mdi-play")
with layout.content:
html_view = paraview.VtkRemoteView(view, interactive_quality=100, style="width: 100%; height: 100%;")
server.controller.view_update = html_view.update
server.controller.view_reset_camera = html_view.reset_camera
if __name__ == "__main__":
server.start() |
Beta Was this translation helpful? Give feedback.
Answered by
jourdain
Nov 14, 2024
Replies: 1 comment 6 replies
-
https://github.com/Kitware/trame/tree/master/examples/07_paraview/TimeAnimation |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
NimaGhorab
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/Kitware/trame/tree/master/examples/07_paraview/TimeAnimation