File: 652.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 (52 lines) | stat: -rw-r--r-- 1,267 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json

from trame.app import get_server
from trame.ui.vuetify import SinglePageWithDrawerLayout
from trame.widgets import vuetify

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

state.sgnodeList = json.loads(
    """[
    {
        "name": "First",
        "visible": false,
        "selfcolor": "#ff643d",
        "selected": true
    },
    {
        "name": "Second",
        "visible": true,
        "selfcolor": "green",
        "selected": false
    }
]"""
)


def changeSelected():
    print("changing selected")


with SinglePageWithDrawerLayout(server, style="overflow: hidden") as layout:
    layout.title.set_text("My App")

    with layout.drawer:
        with vuetify.VList(shaped=True):
            with vuetify.VListItem(v_for="val, idx in sgnodeList", key="idx"):
                vuetify.VSwitch(
                    v_model=("val.visible",),
                    color=("val.selfcolor",),
                )
                with vuetify.VListItemContent():
                    vuetify.VListItemTitle("{{val.name}}")

                vuetify.VCheckbox(
                    v_model=("val.selected",),
                    click=changeSelected,
                )

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