File size: 2,531 Bytes
7798609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'''
title: Menu
'''

import streamsync as ss

ss.md("## ss.menu")

ss.md('''
#### πŸ”… Example
''')

data = [
    {'index': '1', 'title': 'Processing Center', 'icon':'mdi-home'},
    {'type': 'spacer'}, #add spacer
    {
        'index': '2',
        'title': 'Workspace',
        'icon' : 'mdi-plus',
        'subItems': [
            {'index': '2-1', 'title': 'item one'},
            {'index': '2-2', 'title': 'item two'},
            {'index': '2-3', 'title': 'item three'},
            {
                'index': '2-4',
                'title': 'item four',
                'subItems': [
                    {'index': '2-4-1', 'title': 'item one'},
                    {'index': '2-4-2', 'title': 'item two'},
                    {'index': '2-4-3', 'title': 'item three'},
                ],
            },
        ],
    },
    {'index': '3', 'title': 'Info', 'disabled': True, 'icon':'mdi-cancel'},
    {'index': '4', 'title': 'Orders', 'icon':'mdi-wrench'},
]

def menu_select(event):
    print("menu1")
    ss.message(event.data["keyPath"])

    
ss.md("### Horiontal Menu")
ss.menu(data, direction = "horizontal", onselect = menu_select)

ss.space()
ss.md("### Vertical Menu")

ss.menu(data, direction = "vertical", dark = True, onselect = menu_select)


ss.space()
ss.write('''
---
#### πŸ”Ž Code
''')

ss.md('''
```python
import simplestart as ss

data = [
    {'index': '1', 'title': 'Processing Center', 'icon':'mdi-home'},
    {'type': 'spacer'}, #add spacer
    {
        'index': '2',
        'title': 'Workspace',
        'icon' : 'mdi-plus',
        'subItems': [
            {'index': '2-1', 'title': 'item one'},
            {'index': '2-2', 'title': 'item two'},
            {'index': '2-3', 'title': 'item three'},
            {
                'index': '2-4',
                'title': 'item four',
                'subItems': [
                    {'index': '2-4-1', 'title': 'item one'},
                    {'index': '2-4-2', 'title': 'item two'},
                    {'index': '2-4-3', 'title': 'item three'},
                ],
            },
        ],
    },
    {'index': '3', 'title': 'Info', 'disabled': True, 'icon':'mdi-cancel'},
    {'index': '4', 'title': 'Orders', 'icon':'mdi-wrench'},
]

def menu_select(event):
    print("menu1")
    ss.message(event.data["keyPath"])

    
ss.md("### Horiontal Menu")
ss.menu(data, direction = "horizontal", onselect = menu_select)

ss.space()
ss.md("### Vertical Menu")

ss.menu(data, direction = "vertical", dark = True, onselect = menu_select)

```
''')