Dynamically updating components of a layout #399
Replies: 3 comments 4 replies
-
Dear Rob,
Yes, trame can do this. You could use multiple tabs, which is a static
workflow, but the web is pretty dynamic and holds a number of possibilities
for your use case.
Try using "v_show=expression" as a parameter to the containers or layout
holding the component. If the expression evaluates to true, then the
component takes space and is displayed; otherwise, it does not take up any
space and is not displayed.
Best regards,
Patrick
…On Wed, Dec 27, 2023 at 8:59 PM Rob Oakes ***@***.***> wrote:
Dear Kitware,
I recently came across Trame and the capabilities are really astounding.
It is a very nicely done framework for creating rich applications for 3D
visualization, analysis, and interaction.
I'm currently working on a proof-of-concept application that has a couple
of steps joined together in a workflow. In step 1, the user selects some
data. In step 2, they manipulate some parameters via a set of controls.
Then in step 3, they visualize their results.
Is there a way to dynamically modify the components of a layout? For
example, can I render one set of controls in step 1; clear those for step 2
and load a new set of components; then clear those for step 3 and load the
resulting outcome?
Is Trame designed for implementing these types of workflows?
Best Regards,
Rob Oakes
—
Reply to this email directly, view it on GitHub
<#399>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYGDMOL3N2YS3YDTSQMKGDYLTVCJAVCNFSM6AAAAABBFBBHV2VHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWGAYDKOBTG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi Patrick, Thank you for getting back to me. I'll start playing with the I'm playing with some strategies now (and if you don't mind keeping this discussion open), I'll post some code/screenshots and love to get some feedback. One need I haven't figured out how to do is similar to the use-case described above. The application will be used for planning surgeries, and for that reason, needs to load medical imaging volumes and 3D meshes. For the meshes, I would like to create a set of controls to allow the user to modify the opacity, color, and other properties (one set of controls for each mesh); but I haven't been able to figure out how that should work since the imaging data is not loaded at the time that the widgets are declared. Any feedback is appreciated. Cheers, |
Beta Was this translation helpful? Give feedback.
-
While the path @patrickoleary suggests is recommended for performance and general architecture, you can also redefine the main layout in functions, as in the example below. Moreover, you can use trame-router to better manage multi-pages and sub-sections of the UI update. from trame.app import get_server
from trame.decorators import TrameApp, change
from trame.ui.html import DivLayout
from trame.widgets import html
CLIENT_TYPE="vue2" # or "vue3"
@TrameApp()
class Example:
def __init__(self, server=None):
self.server = get_server(server, client_type=CLIENT_TYPE)
self.server.state.active_page = "page_1"
@change("active_page")
def go_to_page(self, active_page, **kwargs):
getattr(self, active_page)()
def page_1(self):
with DivLayout(self.server) as layout:
html.Div("Page 1")
with html.Select(v_model="active_page"):
html.Option("Page 1", value="page_1")
html.Option("Page 2", value="page_2")
html.Option("Page 3", value="page_3")
def page_2(self):
with DivLayout(self.server) as layout:
html.Div("Page 2")
with html.Select(v_model="active_page"):
html.Option("Page 1", value="page_1")
html.Option("Page 2", value="page_2")
html.Option("Page 3", value="page_3")
def page_3(self):
with DivLayout(self.server) as layout:
html.Div("Page 3")
with html.Select(v_model="active_page"):
html.Option("Page 1", value="page_1")
html.Option("Page 2", value="page_2")
html.Option("Page 3", value="page_3")
if __name__ == "__main__":
app = Example()
app.server.start() Feel free to contact Kitware so we can help you make the best of trame and VTK. |
Beta Was this translation helpful? Give feedback.
-
Dear Kitware,
I recently came across Trame and the capabilities are really astounding. It is a very nicely done framework for creating rich applications for 3D visualization, analysis, and interaction.
I'm currently working on a proof-of-concept application that has a couple of steps joined together in a workflow. In step 1, the user selects some data. In step 2, they manipulate some parameters via a set of controls. Then in step 3, they visualize their results.
Is there a way to dynamically modify the components of a layout? For example, can I render one set of controls in step 1; clear those for step 2 and load a new set of components; then clear those for step 3 and load the resulting outcome?
Is Trame designed for implementing these types of workflows?
Best Regards,
Rob Oakes
Beta Was this translation helpful? Give feedback.
All reactions