0

Is there any way to tell iPython/Juypter to process any widget events in the middle of a sleep loop?

I've seen the async examples, but they don't make sense to me. Is there a simpler way?

I want to do something like this:

for i in range(3):
    button_response = None
    clear_output()
    display_trial_widget(i, ...)
    while not button_response:
        # Let iPython handle all widget events...
        time.sleep(0.1)
    save_response_and_modify_trial()

The trial widget plays some audio, and expects the user to click one of two buttons in response.

Is there something simple I can put in the while loop so that iPython widgets can do their thing? I'm doing this in a Juypter notebook running on MacOSX.

Here is the current UI: Widget UI

Thanks.

1 Answers1

0

OK, that was a dumb question.

A better way is to make everything event based, as was done in this answer. Python onclick button widget return object

This way a button event causes the next screen to be drawn. No need for a wait loop.