1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
from trame.app import get_server
from trame.widgets import html
from trame.ui.html import DivLayout
server = get_server()
server.client_type = "vue2"
state, ctrl = server.state, server.controller
state.count = 2
state.double = 4
@state.change("count")
def update_count(count, **kwargs):
state.double = 2 * int(count)
with DivLayout(server) as layout:
html.Div("count = {{ count }}")
html.Div("2 x count = {{ double }}")
html.Input(
type="range",
min=0,
max=10,
step=1,
v_model="count",
)
server.start()
|