Reset interact control between two uses

asked 2021-04-17 09:08:44 +0100

SB gravatar image

I use interact and between two evaluation, I would like the control to come back to its default position, how could I do that?

Here is a simplified example:

a = 0
@interact
def _(b = selector([(-1,""),(0,"0"),(1,"1"),(2,"2")]), auto_update=False):
    global a
    if b != -1:
        a = a + b
    print(a)

I would like the selector to come back to the position (-1,"") after an evaluation.

Would someone know how to do that?

edit retag flag offensive close merge delete