dataclass
- class trame.widgets.dataclass.Gui(**kwargs)
Bases:
AbstractElementRenders the auto-generated GUI template for a
StateDataModelinstance.The component looks up the class definition registered for the bound instance and renders the Vue template returned by
generate_gui(). Bind the target instance via theinstanceattribute:dataclass.Gui(instance=(f"'{model._id}'",))
- class trame.widgets.dataclass.Provider(name, **kwargs)
Bases:
AbstractElementWraps a
StateDataModelinstance and exposes it to a scoped Vue slot.Within the slot, the bound model is available as the variable name and a boolean
{name}_availableindicates whether the instance has been received by the client.Two common patterns:
Fixed instance — use the
provide_asshorthand on the model itself:with model.provide_as("user"): vuetify.VTextField(v_model=("user.name",))
Reactive instance — bind to a trame state variable that holds the instance ID, so the provided model can change at runtime:
with dataclass.Provider(name="active_user", instance=("active_user_id", None)): html.Pre("{{ JSON.stringify(active_user, null, 2) }}")