How to communicate interactively in trame server and client?

Hi, I use trame_tutorial/04_application/solution.py(https://github.com/Kitware/trame-tutorial/blob/master/04_application/solution.py) to display my vtu file, and it worked. Now I want to create a trame client to interact with the server. Can someone give me an example or give some reference?


I create a trame client, then how to communciate with the server? I want to control the selection drop-down box and Opactiy through the client.

Can you elaborate on what you mean by trame client? (browser, javascript component, another python process, …, ?)

My goal is to use a python process to control the graphic display on the server side. So I want to use the trame.app.get_client api to create a client instance in a Python script. I read some source code, it should be communicated with websocket, but I don’t know how to do it.

I see, so you have a fully working trame app (client+server), but you want another process (python) to start driving that app “remotely”.

Then indeed the get_client method is the way to go. Except that the url that needs to be passed is the websocket endpoint not the http website.

Once connected, you will have access to a state variable that let you do the same thing as on the server. You can modify it or react to it.

With that example, you can see that the url passed is ws://localhost:1234/ws. But that assume, the main trame process is ran locally with --port 1234 as arg.

Does it make sense?

Thanks a lot, this example is exactly what I was looking for. I built my app with this and it worked.

1 Like