I would like to respond to a button click without updating or changing the ui (e.g. just do a print()
for now). If I try with h2o-wave v1.0.2 on Win10-22H2, the ui seems to hang in an infinite loading spinner.
This behavior only applies to mode='unicast'
, which is the default. In case of mode='multicast'
and mode='broadcast'
, the ui and the app behave as expected (i.e. print()
works fine, ui stays responsive).
The problem seems to be independent of browser (tried with Firefox 122.0.1 and MS-Edge 121.0.2277.112).
In the following boilerplate, every works fine, i.e. print()
and ui updates happen as expected:
from h2o_wave import main, app, Q, ui
@app('/buttons', mode='broadcast')
async def serve(q: Q):
if not q.client.initialized:
q.page['form'] = ui.form_card(box='1 1 2 2', items=[
ui.buttons([
ui.button(name='btn1', label='BTN-1'),
ui.button(name='btn2', label='BTN-2')
]),
ui.text_m(name='text', content='Click on a button ...'),
])
q.client.initialized = True
if q.args.btn1:
print(f'{q.args.btn1=}')
print(f'{q.args.btn2=}')
q.page['form'].text.content = 'btn1 was pressed.'
if q.args.btn2:
print(f'{q.args.btn1=}')
print(f'{q.args.btn2=}')
q.page['form'].text.content = 'btn2 was pressed.'
await q.page.save()
If line q.page['form'].text.content = 'btn1 was pressed.'
is removed, the ui seems to hang in an infinite loading spinner (tried to post an image, but I am new on stackoverflow hence not yet allowed).
This holds true indipendent of applying await q.page.save()
or not.
The application works fine as soon as I use mode='multicast'
or mode='broadcast'
(which is not what I need in my case).
What would be the correct way in mode='unicast'
to handle a button click without updating the ui?