You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been attempting to create a page which shows the status of a long-running process when a button is pressed etc. I'm trying to understand a behaviour difference when clicking a button or setting a value with a Select widget.
In the example below, clicking the button triggers a 1s process and a visible temporary "running" status. Using a Select to trigger the process works but the status is not kept up to date.
Perhaps I am missing something key about the "on_value" call back of Select.
import solara as sl
import time
@sl.component
def Page():
status,set_status = sl.use_state('ready')
value,set_value = sl.use_state(0)
def run():
set_status('running')
time.sleep(1)
set_value(value+1)
set_status('ready')
with sl.Column():
sl.Text(f'value = {value}')
sl.Text(f'status = {status}')
sl.Button(label='Add with button', on_click=run,)
sl.Select(
label='Add with select',
values=('1','2'),
value=None,
on_value=lambda value:run())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been attempting to create a page which shows the status of a long-running process when a button is pressed etc. I'm trying to understand a behaviour difference when clicking a button or setting a value with a Select widget.
In the example below, clicking the button triggers a 1s process and a visible temporary "running" status. Using a Select to trigger the process works but the status is not kept up to date.
Perhaps I am missing something key about the "on_value" call back of Select.
Beta Was this translation helpful? Give feedback.
All reactions