File: dynamic_template.py

package info (click to toggle)
python-trame-client 3.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,128 kB
  • sloc: python: 9,609; javascript: 3,897; sh: 9; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 707 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from trame.app import get_server
from trame.widgets import html
from trame.ui.html import DivLayout
from trame_client.utils.testing import enable_testing

server = enable_testing(get_server(client_type="vue2"), "count")
state, ctrl = server.state, server.controller

state.count = 1


def update_ui():
    state.count += 1
    with DivLayout(server):
        html.Div(f"Static text {state.count}", classes="staticDiv")
        html.Div("count = {{ count }}", classes="countDiv")
        html.Div("tts = {{ tts }}", classes="ttsDiv")
        html.Button("Update template", click=update_ui, classes="updateBtn")
        html.Button("count++", click="count++", classes="plusBtn")


update_ui()

server.start()