File: 04_update_template.py

package info (click to toggle)
python-trame 3.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 863 bytes parent folder | download | duplicates (2)
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
30
31
from trame.app import get_server
from trame.ui.html import DivLayout
from trame.widgets import html, trame

LINE_COUNT = 1

# -----------------------------------------------------------------------------
# Trame setup
# -----------------------------------------------------------------------------

server = get_server()
layout = DivLayout(server)


def add_new_line():
    global LINE_COUNT
    with layout as c:
        c.root.add_child(f"<br>New line {LINE_COUNT}")
        LINE_COUNT += 1


with layout:
    html.Button("Add a new line ({{ tts }})", click=add_new_line)
    trame.LifeCycleMonitor(type="error", events=("['created']",))

# -----------------------------------------------------------------------------
# start server
# -----------------------------------------------------------------------------

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