-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo2.py
30 lines (26 loc) · 1.04 KB
/
demo2.py
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
from h2o_wave import main, app, Q, ui
@app('/demo')
async def serve(q: Q):
print(q.auth.username)
if not q.client.initialized:
q.page['meta'] = ui.meta_card(box='', script=ui.inline_script(
# Handle and transmit event
'window.onclick = (e) => wave.emit("window", "clicked", { x: e.clientX, y: e.clientY });'
))
q.page['quote'] = ui.markdown_card(
box='1 1 2 2',
title='Hello World',
content='"The Internet? Is that thing still around?" - *Homer Simpson*',)
q.page['quote2'] = ui.markdown_card(
box='1 2 2 2',
title='demo2',
content='"The Internet? Is that thing still around?" - *Homer Simpson*',)
q.client.initialized = True
else:
# Capture event
if q.events.window:
click = q.events.window.clicked
if click:
print(click['x'], click['y'])
q.page['quote2'].content = f'Clicked at {click["x"]}, {click["y"]}'
await q.page.save()