-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtoolbar_control.py
More file actions
149 lines (139 loc) · 4.7 KB
/
toolbar_control.py
File metadata and controls
149 lines (139 loc) · 4.7 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import pglet
from pglet import Stack, Text, Toolbar, Message
from pglet import toolbar
def toolbars(page):
def item_clicked(e):
page.controls.insert(
0, Message(value=f'Menu item "{e.control.text}" was clicked', dismiss=True)
)
page.update()
standard_toolbar = Toolbar(
items=[
toolbar.Item(
text="New",
icon="Add",
items=[
toolbar.Item(
text="Email message", icon="Mail", on_click=item_clicked
),
toolbar.Item(
text="Calendar event", icon="Calendar", on_click=item_clicked
),
],
),
toolbar.Item(
text="Share",
icon="Share",
split=True,
items=[
toolbar.Item(text="Share to Twitter", on_click=item_clicked),
toolbar.Item(text="Share to Facebook", on_click=item_clicked),
toolbar.Item(
text="Share to Somewhere", disabled=True, on_click=item_clicked
),
toolbar.Item(
text="Share to Email",
data="sharetoemail",
items=[
toolbar.Item(
text="Share to Outlook", on_click=item_clicked
),
toolbar.Item(text="Share to Gmail", on_click=item_clicked),
],
),
],
),
toolbar.Item(
text="To to Google",
icon="Globe",
url="https://google.com",
new_window=True,
secondary_text="New window",
),
],
overflow=[
toolbar.Item(text="Item 1", icon="Shop", on_click=item_clicked),
toolbar.Item(text="Item 2", icon="Airplane", on_click=item_clicked),
],
far=[
toolbar.Item(
text="Grid view", icon="Tiles", icon_only=True, on_click=item_clicked
),
toolbar.Item(
text="Info",
icon="Info",
icon_color="green",
icon_only=True,
on_click=item_clicked,
),
],
)
inverted_toolbar = Toolbar(
inverted=True,
items=[
toolbar.Item(
text="New",
icon="Add",
items=[
toolbar.Item(text="Email message", icon="Mail"),
toolbar.Item(text="Calendar event", icon="Calendar"),
],
),
toolbar.Item(
text="Share",
icon="Share",
split=True,
items=[
toolbar.Item(text="Share to Twitter"),
toolbar.Item(text="Share to Facebook"),
toolbar.Item(text="Share to Somewhere", disabled=True),
toolbar.Item(
text="Share to Email",
data="sharetoemail",
items=[
toolbar.Item(text="Share to Outlook"),
toolbar.Item(text="Share to Gmail"),
],
),
],
),
toolbar.Item(
text="To to Google",
icon="Globe",
url="https://google.com",
new_window=True,
secondary_text="New window",
),
],
overflow=[
toolbar.Item(text="Item 1", icon="Shop"),
toolbar.Item(text="Item 2", icon="Airplane"),
],
far=[
toolbar.Item(text="Grid view", icon="Tiles", icon_only=True),
toolbar.Item(text="Info", icon="Info", icon_color="green", icon_only=True),
],
)
return Stack(
gap=30,
controls=[
Stack(
controls=[
Text("Standard toolbar with Click events", size="xLarge"),
standard_toolbar,
]
),
Stack(
controls=[
Text("Inverted toolbar (for top application menu)", size="xLarge"),
Stack(bgcolor="magentaLight", controls=[inverted_toolbar]),
]
),
],
)
def main(page):
page.title = "Toolbar control samples"
page.horizontal_align = "stretch"
page.update()
page.add(toolbars(page))
pglet.app("python-toolbar", target=main)