Created
September 6, 2022 16:14
-
-
Save mturoci/91cf5f187a3efc204f4e47a27461d6fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, Q, ui | |
@app('/') | |
async def serve(q: Q): | |
# Run this part only once, when the browser first connects. | |
if not q.client.initialized: | |
# Create a navigation card. | |
q.page['nav'] = ui.nav_card( | |
box='1 1 2 -1', | |
# Use default value initially. | |
value='#menu/spam', | |
title='H2O Wave', | |
items=[ | |
ui.nav_group('Menu', items=[ | |
ui.nav_item(name='#menu/spam', label='Spam'), | |
ui.nav_item(name='#menu/ham', label='Ham'), | |
ui.nav_item(name='#menu/eggs', label='Eggs'), | |
ui.nav_item(name='#menu/toast', label='Toast'), | |
]) | |
] | |
) | |
q.client.initialized = True | |
# Check if a link is clicked or active in URL. | |
if q.args['#'] is not None: | |
# Update just the value. | |
q.page['nav'].value = f'#{q.args["#"]}' | |
await q.page.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment