mercredi 12 juin 2019

How to start and stop a while-loop with an ipywidget interactive Checkbox?

i try to start and stop a while-loop with a simple checkbox. But i don't know how i am able to update the checkbox-state in the while loop.

Below you can see what i have, but when i uncheck the box, the while loop won't recognize it.

I searched through the interactive functions but have not found any function to get the updated state of the checkbox.

Hope you guys can help me out :)

import ipywidgets
import time

def f(x):
    while x==True:
        print("!")
        time.sleep(1)

c=ipywidgets.interactive(f,x=False)
c




Aucun commentaire:

Enregistrer un commentaire