h2o-wave 0.26.3__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of h2o-wave might be problematic. Click here for more details.

@@ -1,218 +0,0 @@
1
- from h2o_wave import main, app, Q, ui, on, handle_on, data
2
- from typing import Optional, List
3
-
4
-
5
- # Use for page cards that should be removed when navigating away.
6
- # For pages that should be always present on screen use q.page[key] = ...
7
- def add_card(q, name, card) -> None:
8
- q.client.cards.add(name)
9
- q.page[name] = card
10
-
11
-
12
- # Remove all the cards related to navigation.
13
- def clear_cards(q, ignore: Optional[List[str]] = []) -> None:
14
- if not q.client.cards:
15
- return
16
- for name in q.client.cards.copy():
17
- if name not in ignore:
18
- del q.page[name]
19
- q.client.cards.remove(name)
20
-
21
-
22
- @on('#page1')
23
- async def page1(q: Q):
24
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
25
-
26
- for i in range(3):
27
- add_card(q, f'info{i}', ui.tall_info_card(box='horizontal', name='', title='Speed',
28
- caption='The models are performant thanks to...', icon='SpeedHigh'))
29
- add_card(q, 'article', ui.tall_article_preview_card(
30
- box=ui.box('vertical', height='600px'), title='How does magic work',
31
- image='https://images.pexels.com/photos/624015/pexels-photo-624015.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
32
- content='''
33
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac sodales felis. Duis orci enim, iaculis at augue vel, mattis imperdiet ligula. Sed a placerat lacus, vitae viverra ante. Duis laoreet purus sit amet orci lacinia, non facilisis ipsum venenatis. Duis bibendum malesuada urna. Praesent vehicula tempor volutpat. In sem augue, blandit a tempus sit amet, tristique vehicula nisl. Duis molestie vel nisl a blandit. Nunc mollis ullamcorper elementum.
34
- Donec in erat augue. Nullam mollis ligula nec massa semper, laoreet pellentesque nulla ullamcorper. In ante ex, tristique et mollis id, facilisis non metus. Aliquam neque eros, semper id finibus eu, pellentesque ac magna. Aliquam convallis eros ut erat mollis, sit amet scelerisque ex pretium. Nulla sodales lacus a tellus molestie blandit. Praesent molestie elit viverra, congue purus vel, cursus sem. Donec malesuada libero ut nulla bibendum, in condimentum massa pretium. Aliquam erat volutpat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer vel tincidunt purus, congue suscipit neque. Fusce eget lacus nibh. Sed vestibulum neque id erat accumsan, a faucibus leo malesuada. Curabitur varius ligula a velit aliquet tincidunt. Donec vehicula ligula sit amet nunc tempus, non fermentum odio rhoncus.
35
- Vestibulum condimentum consectetur aliquet. Phasellus mollis at nulla vel blandit. Praesent at ligula nulla. Curabitur enim tellus, congue id tempor at, malesuada sed augue. Nulla in justo in libero condimentum euismod. Integer aliquet, velit id convallis maximus, nisl dui porta velit, et pellentesque ligula lorem non nunc. Sed tincidunt purus non elit ultrices egestas quis eu mauris. Sed molestie vulputate enim, a vehicula nibh pulvinar sit amet. Nullam auctor sapien est, et aliquet dui congue ornare. Donec pulvinar scelerisque justo, nec scelerisque velit maximus eget. Ut ac lectus velit. Pellentesque bibendum ex sit amet cursus commodo. Fusce congue metus at elementum ultricies. Suspendisse non rhoncus risus. In hac habitasse platea dictumst.
36
- '''
37
- ))
38
-
39
-
40
- @on('#page2')
41
- async def page2(q: Q):
42
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
43
- add_card(q, 'chart1', ui.plot_card(
44
- box='horizontal',
45
- title='Chart 1',
46
- data=data('category country product price', 10, rows=[
47
- ('G1', 'USA', 'P1', 124),
48
- ('G1', 'China', 'P2', 580),
49
- ('G1', 'USA', 'P3', 528),
50
- ('G1', 'China', 'P1', 361),
51
- ('G1', 'USA', 'P2', 228),
52
- ('G2', 'China', 'P3', 418),
53
- ('G2', 'USA', 'P1', 824),
54
- ('G2', 'China', 'P2', 539),
55
- ('G2', 'USA', 'P3', 712),
56
- ('G2', 'USA', 'P1', 213),
57
- ]),
58
- plot=ui.plot([ui.mark(type='interval', x='=product', y='=price', color='=country', stack='auto',
59
- dodge='=category', y_min=0)])
60
- ))
61
- add_card(q, 'chart2', ui.plot_card(
62
- box='horizontal',
63
- title='Chart 2',
64
- data=data('date price', 10, rows=[
65
- ('2020-03-20', 124),
66
- ('2020-05-18', 580),
67
- ('2020-08-24', 528),
68
- ('2020-02-12', 361),
69
- ('2020-03-11', 228),
70
- ('2020-09-26', 418),
71
- ('2020-11-12', 824),
72
- ('2020-12-21', 539),
73
- ('2020-03-18', 712),
74
- ('2020-07-11', 213),
75
- ]),
76
- plot=ui.plot([ui.mark(type='line', x_scale='time', x='=date', y='=price', y_min=0)])
77
- ))
78
- add_card(q, 'table', ui.form_card(box='vertical', items=[ui.table(
79
- name='table',
80
- downloadable=True,
81
- resettable=True,
82
- groupable=True,
83
- columns=[
84
- ui.table_column(name='text', label='Process', searchable=True),
85
- ui.table_column(name='tag', label='Status', filterable=True, cell_type=ui.tag_table_cell_type(
86
- name='tags',
87
- tags=[
88
- ui.tag(label='FAIL', color='$red'),
89
- ui.tag(label='DONE', color='#D2E3F8', label_color='#053975'),
90
- ui.tag(label='SUCCESS', color='$mint'),
91
- ]
92
- ))
93
- ],
94
- rows=[
95
- ui.table_row(name='row1', cells=['Process 1', 'FAIL']),
96
- ui.table_row(name='row2', cells=['Process 2', 'SUCCESS,DONE']),
97
- ui.table_row(name='row3', cells=['Process 3', 'DONE']),
98
- ui.table_row(name='row4', cells=['Process 4', 'FAIL']),
99
- ui.table_row(name='row5', cells=['Process 5', 'SUCCESS,DONE']),
100
- ui.table_row(name='row6', cells=['Process 6', 'DONE']),
101
- ])
102
- ]))
103
-
104
-
105
- @on('#page3')
106
- async def page3(q: Q):
107
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
108
-
109
- for i in range(12):
110
- add_card(q, f'item{i}', ui.wide_info_card(box=ui.box('grid', width='400px'), name='', title='Tile',
111
- caption='Lorem ipsum dolor sit amet'))
112
-
113
-
114
- @on('#page4')
115
- async def handle_page4(q: Q):
116
- # When routing, drop all the cards except of the main ones (header, sidebar, meta).
117
- # Since this page is interactive, we want to update its card instead of recreating it every time, so ignore 'form' card on drop.
118
- clear_cards(q, ['form'])
119
-
120
- if q.args.step1:
121
- # Just update the existing card, do not recreate.
122
- q.page['form'].items = [
123
- ui.stepper(name='stepper', items=[
124
- ui.step(label='Step 1'),
125
- ui.step(label='Step 2'),
126
- ui.step(label='Step 3'),
127
- ]),
128
- ui.textbox(name='textbox2', label='Textbox 1'),
129
- ui.buttons(justify='end', items=[
130
- ui.button(name='step2', label='Next', primary=True),
131
- ])
132
- ]
133
- elif q.args.step2:
134
- # Just update the existing card, do not recreate.
135
- q.page['form'].items = [
136
- ui.stepper(name='stepper', items=[
137
- ui.step(label='Step 1', done=True),
138
- ui.step(label='Step 2'),
139
- ui.step(label='Step 3'),
140
- ]),
141
- ui.textbox(name='textbox2', label='Textbox 2'),
142
- ui.buttons(justify='end', items=[
143
- ui.button(name='step1', label='Cancel'),
144
- ui.button(name='step3', label='Next', primary=True),
145
- ])
146
- ]
147
- elif q.args.step3:
148
- # Just update the existing card, do not recreate.
149
- q.page['form'].items = [
150
- ui.stepper(name='stepper', items=[
151
- ui.step(label='Step 1', done=True),
152
- ui.step(label='Step 2', done=True),
153
- ui.step(label='Step 3'),
154
- ]),
155
- ui.textbox(name='textbox3', label='Textbox 3'),
156
- ui.buttons(justify='end', items=[
157
- ui.button(name='step2', label='Cancel'),
158
- ui.button(name='submit', label='Next', primary=True),
159
- ])
160
- ]
161
- else:
162
- # If first time on this page, create the card.
163
- add_card(q, 'form', ui.form_card(box='vertical', items=[
164
- ui.stepper(name='stepper', items=[
165
- ui.step(label='Step 1'),
166
- ui.step(label='Step 2'),
167
- ui.step(label='Step 3'),
168
- ]),
169
- ui.textbox(name='textbox1', label='Textbox 1'),
170
- ui.buttons(justify='end', items=[
171
- ui.button(name='step2', label='Next', primary=True),
172
- ]),
173
- ]))
174
-
175
-
176
- async def init(q: Q) -> None:
177
- q.page['meta'] = ui.meta_card(box='', layouts=[ui.layout(breakpoint='xs', min_height='100vh', zones=[
178
- ui.zone('header'),
179
- ui.zone('content', zones=[
180
- # Specify various zones and use the one that is currently needed. Empty zones are ignored.
181
- ui.zone('horizontal', direction=ui.ZoneDirection.ROW),
182
- ui.zone('vertical'),
183
- ui.zone('grid', direction=ui.ZoneDirection.ROW, wrap='stretch', justify='center')
184
- ]),
185
- ])])
186
- q.page['header'] = ui.header_card(
187
- box='header', title='My app', subtitle="Let's conquer the world",
188
- image='https://wave.h2o.ai/img/h2o-logo.svg',
189
- secondary_items=[
190
- ui.tabs(name='tabs', value=f'#{q.args["#"]}' if q.args['#'] else '#page1', link=True, items=[
191
- ui.tab(name='#page1', label='Home'),
192
- ui.tab(name='#page2', label='Charts'),
193
- ui.tab(name='#page3', label='Grid'),
194
- ui.tab(name='#page4', label='Form'),
195
- ]),
196
- ],
197
- items=[
198
- ui.persona(title='John Doe', subtitle='Developer', size='xs',
199
- image='https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&h=750&w=1260'),
200
- ]
201
- )
202
- # If no active hash present, render page1.
203
- if q.args['#'] is None:
204
- await page1(q)
205
-
206
-
207
- @app('/')
208
- async def serve(q: Q):
209
- # Run only once per client connection.
210
- if not q.client.initialized:
211
- q.client.cards = set()
212
- await init(q)
213
- q.client.initialized = True
214
-
215
- # Handle routing.
216
- await handle_on(q)
217
- await q.page.save()
218
-
@@ -1,232 +0,0 @@
1
-
2
- from h2o_wave import main, app, Q, ui, on, handle_on, data
3
- from typing import Optional, List
4
-
5
-
6
- # Use for page cards that should be removed when navigating away.
7
- # For pages that should be always present on screen use q.page[key] = ...
8
- def add_card(q, name, card) -> None:
9
- q.client.cards.add(name)
10
- q.page[name] = card
11
-
12
-
13
- # Remove all the cards related to navigation.
14
- def clear_cards(q, ignore: Optional[List[str]] = []) -> None:
15
- if not q.client.cards:
16
- return
17
-
18
- for name in q.client.cards.copy():
19
- if name not in ignore:
20
- del q.page[name]
21
- q.client.cards.remove(name)
22
-
23
-
24
- @on('#page1')
25
- async def page1(q: Q):
26
- q.page['sidebar'].value = '#page1'
27
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
28
-
29
- for i in range(3):
30
- add_card(q, f'info{i}', ui.tall_info_card(box='horizontal', name='', title='Speed',
31
- caption='The models are performant thanks to...', icon='SpeedHigh'))
32
- add_card(q, 'article', ui.tall_article_preview_card(
33
- box=ui.box('vertical', height='600px'), title='How does magic work',
34
- image='https://images.pexels.com/photos/624015/pexels-photo-624015.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
35
- content='''
36
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac sodales felis. Duis orci enim, iaculis at augue vel, mattis imperdiet ligula. Sed a placerat lacus, vitae viverra ante. Duis laoreet purus sit amet orci lacinia, non facilisis ipsum venenatis. Duis bibendum malesuada urna. Praesent vehicula tempor volutpat. In sem augue, blandit a tempus sit amet, tristique vehicula nisl. Duis molestie vel nisl a blandit. Nunc mollis ullamcorper elementum.
37
- Donec in erat augue. Nullam mollis ligula nec massa semper, laoreet pellentesque nulla ullamcorper. In ante ex, tristique et mollis id, facilisis non metus. Aliquam neque eros, semper id finibus eu, pellentesque ac magna. Aliquam convallis eros ut erat mollis, sit amet scelerisque ex pretium. Nulla sodales lacus a tellus molestie blandit. Praesent molestie elit viverra, congue purus vel, cursus sem. Donec malesuada libero ut nulla bibendum, in condimentum massa pretium. Aliquam erat volutpat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer vel tincidunt purus, congue suscipit neque. Fusce eget lacus nibh. Sed vestibulum neque id erat accumsan, a faucibus leo malesuada. Curabitur varius ligula a velit aliquet tincidunt. Donec vehicula ligula sit amet nunc tempus, non fermentum odio rhoncus.
38
- Vestibulum condimentum consectetur aliquet. Phasellus mollis at nulla vel blandit. Praesent at ligula nulla. Curabitur enim tellus, congue id tempor at, malesuada sed augue. Nulla in justo in libero condimentum euismod. Integer aliquet, velit id convallis maximus, nisl dui porta velit, et pellentesque ligula lorem non nunc. Sed tincidunt purus non elit ultrices egestas quis eu mauris. Sed molestie vulputate enim, a vehicula nibh pulvinar sit amet. Nullam auctor sapien est, et aliquet dui congue ornare. Donec pulvinar scelerisque justo, nec scelerisque velit maximus eget. Ut ac lectus velit. Pellentesque bibendum ex sit amet cursus commodo. Fusce congue metus at elementum ultricies. Suspendisse non rhoncus risus. In hac habitasse platea dictumst.
39
- '''
40
- ))
41
-
42
-
43
- @on('#page2')
44
- async def page2(q: Q):
45
- q.page['sidebar'].value = '#page2'
46
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
47
- add_card(q, 'chart1', ui.plot_card(
48
- box='horizontal',
49
- title='Chart 1',
50
- data=data('category country product price', 10, rows=[
51
- ('G1', 'USA', 'P1', 124),
52
- ('G1', 'China', 'P2', 580),
53
- ('G1', 'USA', 'P3', 528),
54
- ('G1', 'China', 'P1', 361),
55
- ('G1', 'USA', 'P2', 228),
56
- ('G2', 'China', 'P3', 418),
57
- ('G2', 'USA', 'P1', 824),
58
- ('G2', 'China', 'P2', 539),
59
- ('G2', 'USA', 'P3', 712),
60
- ('G2', 'USA', 'P1', 213),
61
- ]),
62
- plot=ui.plot([ui.mark(type='interval', x='=product', y='=price', color='=country', stack='auto',
63
- dodge='=category', y_min=0)])
64
- ))
65
- add_card(q, 'chart2', ui.plot_card(
66
- box='horizontal',
67
- title='Chart 2',
68
- data=data('date price', 10, rows=[
69
- ('2020-03-20', 124),
70
- ('2020-05-18', 580),
71
- ('2020-08-24', 528),
72
- ('2020-02-12', 361),
73
- ('2020-03-11', 228),
74
- ('2020-09-26', 418),
75
- ('2020-11-12', 824),
76
- ('2020-12-21', 539),
77
- ('2020-03-18', 712),
78
- ('2020-07-11', 213),
79
- ]),
80
- plot=ui.plot([ui.mark(type='line', x_scale='time', x='=date', y='=price', y_min=0)])
81
- ))
82
- add_card(q, 'table', ui.form_card(box='vertical', items=[ui.table(
83
- name='table',
84
- downloadable=True,
85
- resettable=True,
86
- groupable=True,
87
- columns=[
88
- ui.table_column(name='text', label='Process', searchable=True),
89
- ui.table_column(name='tag', label='Status', filterable=True, cell_type=ui.tag_table_cell_type(
90
- name='tags',
91
- tags=[
92
- ui.tag(label='FAIL', color='$red'),
93
- ui.tag(label='DONE', color='#D2E3F8', label_color='#053975'),
94
- ui.tag(label='SUCCESS', color='$mint'),
95
- ]
96
- ))
97
- ],
98
- rows=[
99
- ui.table_row(name='row1', cells=['Process 1', 'FAIL']),
100
- ui.table_row(name='row2', cells=['Process 2', 'SUCCESS,DONE']),
101
- ui.table_row(name='row3', cells=['Process 3', 'DONE']),
102
- ui.table_row(name='row4', cells=['Process 4', 'FAIL']),
103
- ui.table_row(name='row5', cells=['Process 5', 'SUCCESS,DONE']),
104
- ui.table_row(name='row6', cells=['Process 6', 'DONE']),
105
- ])
106
- ]))
107
-
108
-
109
- @on('#page3')
110
- async def page3(q: Q):
111
- q.page['sidebar'].value = '#page3'
112
- clear_cards(q) # When routing, drop all the cards except of the main ones (header, sidebar, meta).
113
-
114
- for i in range(12):
115
- add_card(q, f'item{i}', ui.wide_info_card(box=ui.box('grid', width='400px'), name='', title='Tile',
116
- caption='Lorem ipsum dolor sit amet'))
117
-
118
-
119
- @on('#page4')
120
- async def handle_page4(q: Q):
121
- q.page['sidebar'].value = '#page4'
122
- # When routing, drop all the cards except of the main ones (header, sidebar, meta).
123
- # Since this page is interactive, we want to update its card instead of recreating it every time, so ignore 'form' card on drop.
124
- clear_cards(q, ['form'])
125
-
126
- if q.args.step1:
127
- # Just update the existing card, do not recreate.
128
- q.page['form'].items = [
129
- ui.stepper(name='stepper', items=[
130
- ui.step(label='Step 1'),
131
- ui.step(label='Step 2'),
132
- ui.step(label='Step 3'),
133
- ]),
134
- ui.textbox(name='textbox2', label='Textbox 1'),
135
- ui.buttons(justify='end', items=[
136
- ui.button(name='step2', label='Next', primary=True),
137
- ])
138
- ]
139
- elif q.args.step2:
140
- # Just update the existing card, do not recreate.
141
- q.page['form'].items = [
142
- ui.stepper(name='stepper', items=[
143
- ui.step(label='Step 1', done=True),
144
- ui.step(label='Step 2'),
145
- ui.step(label='Step 3'),
146
- ]),
147
- ui.textbox(name='textbox2', label='Textbox 2'),
148
- ui.buttons(justify='end', items=[
149
- ui.button(name='step1', label='Cancel'),
150
- ui.button(name='step3', label='Next', primary=True),
151
- ])
152
- ]
153
- elif q.args.step3:
154
- # Just update the existing card, do not recreate.
155
- q.page['form'].items = [
156
- ui.stepper(name='stepper', items=[
157
- ui.step(label='Step 1', done=True),
158
- ui.step(label='Step 2', done=True),
159
- ui.step(label='Step 3'),
160
- ]),
161
- ui.textbox(name='textbox3', label='Textbox 3'),
162
- ui.buttons(justify='end', items=[
163
- ui.button(name='step2', label='Cancel'),
164
- ui.button(name='submit', label='Next', primary=True),
165
- ])
166
- ]
167
- else:
168
- # If first time on this page, create the card.
169
- add_card(q, 'form', ui.form_card(box='vertical', items=[
170
- ui.stepper(name='stepper', items=[
171
- ui.step(label='Step 1'),
172
- ui.step(label='Step 2'),
173
- ui.step(label='Step 3'),
174
- ]),
175
- ui.textbox(name='textbox1', label='Textbox 1'),
176
- ui.buttons(justify='end', items=[
177
- ui.button(name='step2', label='Next', primary=True),
178
- ]),
179
- ]))
180
-
181
-
182
- async def init(q: Q) -> None:
183
- q.page['meta'] = ui.meta_card(box='', layouts=[ui.layout(breakpoint='xs', min_height='100vh', zones=[
184
- ui.zone('main', size='1', direction=ui.ZoneDirection.ROW, zones=[
185
- ui.zone('sidebar', size='250px'),
186
- ui.zone('body', zones=[
187
- ui.zone('header'),
188
- ui.zone('content', zones=[
189
- # Specify various zones and use the one that is currently needed. Empty zones are ignored.
190
- ui.zone('horizontal', direction=ui.ZoneDirection.ROW),
191
- ui.zone('vertical'),
192
- ui.zone('grid', direction=ui.ZoneDirection.ROW, wrap='stretch', justify='center')
193
- ]),
194
- ]),
195
- ])
196
- ])])
197
- q.page['sidebar'] = ui.nav_card(
198
- box='sidebar', color='primary', title='My App', subtitle="Let's conquer the world!",
199
- value=f'#{q.args["#"]}' if q.args['#'] else '#page1',
200
- image='https://wave.h2o.ai/img/h2o-logo.svg', items=[
201
- ui.nav_group('Menu', items=[
202
- ui.nav_item(name='#page1', label='Home'),
203
- ui.nav_item(name='#page2', label='Charts'),
204
- ui.nav_item(name='#page3', label='Grid'),
205
- ui.nav_item(name='#page4', label='Form'),
206
- ]),
207
- ])
208
- q.page['header'] = ui.header_card(
209
- box='header', title='', subtitle='',
210
- secondary_items=[ui.textbox(name='search', icon='Search', width='400px', placeholder='Search...')],
211
- items=[
212
- ui.persona(title='John Doe', subtitle='Developer', size='xs',
213
- image='https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&h=750&w=1260'),
214
- ]
215
- )
216
- # If no active hash present, render page1.
217
- if q.args['#'] is None:
218
- await page1(q)
219
-
220
-
221
- @app('/')
222
- async def serve(q: Q):
223
- # Run only once per client connection.
224
- if not q.client.initialized:
225
- q.client.cards = set()
226
- await init(q)
227
- q.client.initialized = True
228
-
229
- # Handle routing.
230
- await handle_on(q)
231
- await q.page.save()
232
-
@@ -1,69 +0,0 @@
1
- from h2o_wave import main, app, Q, ui
2
-
3
- # Listen on the root ('/') route - http://localhost:10101 with default settings.
4
- @app('/')
5
- async def serve(q: Q):
6
- # First time a browser comes to the app
7
- if not q.client.initialized:
8
- # Setup counter state.
9
- q.client.count = 0
10
- # Web app metadata.
11
- q.page['meta'] = ui.meta_card(
12
- box='',
13
- # Tab title.
14
- title='Welcome to Wave',
15
- # Layout definitions.
16
- layouts=[
17
- ui.layout(
18
- breakpoint='xs',
19
- min_height='100vh',
20
- max_width='1200px',
21
- zones=[
22
- ui.zone('content', size='1'),
23
- ui.zone('footer'),
24
- ]
25
- )
26
- ]
27
- )
28
- content='''
29
- # 👋 Welcome to H2O Wave
30
-
31
- This is a toy example for you to play around and show you the base concepts like:
32
-
33
- * How to paint UI.
34
- * How to handle interactivity (e.g. button click).
35
- * How to work with application state.
36
-
37
- You can edit **app.py** file, hit save and the app will automatically reload. Once you are done with playing around and want to get deeper knowledge of the framework itself, visit the [docs](https://wave.h2o.ai/) to learn more.
38
-
39
- ## ✨ Interactivity
40
-
41
- Wave interactivity model is very simple: Every widget that is capable of user interaction populates a python q.args dictionary that developer can later handle in code. See the counter example in this app.
42
-
43
- ## 🆘 Asking for help
44
-
45
- If you have any questions, please reach out to [Github Discussions](https://github.com/h2oai/wave/discussions) or our [Discord server](https://discord.gg/GsyvWgzevv).
46
- '''
47
- # Render app body.
48
- q.page['body'] = ui.tall_article_preview_card(
49
- box='content',
50
- title='',
51
- image='https://wave.h2o.ai/img/blog-preview.png',
52
- content=content,
53
- items=[ui.button(name='counter', label=f'Current count: {q.client.count}')]
54
- )
55
- q.page['footer'] = ui.footer_card(
56
- box='footer',
57
- caption='Made with 💛 using [H2O Wave](https://wave.h2o.ai).'
58
- )
59
-
60
- q.client.initialized = True
61
-
62
- # Handle counter button click.
63
- if q.args.counter:
64
- # Update state
65
- q.client.count += 1
66
- # Update the button label.
67
- q.page['body'].counter.label = f'Current count: {q.client.count}'
68
-
69
- await q.page.save()