Trame

3.12.0 · active · verified Tue Apr 14

Trame is an easy-to-use, Python-based framework that lets you create web applications with interactive scientific visualization. It simplifies web development by managing UI layout, state, events, and widgets entirely in Python, abstracting away the need for HTML, CSS, or JavaScript. Trame applications can run locally, remotely, in the cloud, in Jupyter, or on HPC. The library maintains an active release cadence, with version 3.12.0 being the latest stable release.

Warnings

Install

Imports

Quickstart

This quickstart code initializes a Trame server, sets a reactive state variable, and defines a simple single-page layout using Vuetify3 widgets. It creates a card with a title that updates when a button is clicked, demonstrating basic interactivity. The application runs locally and opens in a web browser upon execution.

from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
from trame.widgets import vuetify3 as v3

server = get_server(client_type="vue3") # Explicitly set for clarity in v3+ apps
server.state.name = "Trame"

with SinglePageLayout(server) as layout:
    layout.title.set_text("Hello Trame")
    with layout.content:
        with v3.VContainer(classes="fill-height", fluid=True):
            with v3.VRow(classes="fill-height", align="center", justify="center"):
                with v3.VCol(cols=12, sm=6, md=4):
                    v3.VCard(
                        v3.VCardTitle(classes="headline", children=["Welcome to ", ('name', 'Trame App')]),
                        v3.VCardText("This is a simple Trame application running in Vue3!"),
                        v3.VCardActions(
                            v3.VSpacer(),
                            v3.VBtn('Click me!', click='server.state.name = "Updated Trame"'),
                            v3.VSpacer(),
                        )
                    )

if __name__ == '__main__':
    server.start()

view raw JSON →