File: checkboxes.py

package info (click to toggle)
python-trame 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 940 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
25
26
27
28
29
30
31
from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify

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

state.visibilityList = [True, False, True, False]


def update_visibility(index, visibility):
    state.visibilityList[index] = visibility
    state.dirty("visibilityList")
    print(f"Toggle {index} to {visibility}")


with SinglePageLayout(server) as layout:
    with layout.content:
        with vuetify.VContainer(fluid=True, classes="fill-height pa-0 ma-0"):
            with vuetify.VCol():
                vuetify.VCheckbox(
                    v_for="v, i in visibilityList",
                    key="i",
                    label=("`Hello ${i}`",),
                    v_model=("visibilityList[i]",),
                    change=(update_visibility, "[i, $event]"),
                )


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