interact button reacting twice

asked 2019-10-14 21:16:47 +0100

Hivert gravatar image

I'm trying to update some old interact to the new Jupyter notebook. I'd like to have an interact with buttons, something like the following:

act = []
@interact
def play(move=selector([None] + ["Auto", "Reset"], buttons=True)):
      act.append(move)
      print(act)

However when I press a new button, the applet receive it twice. For example, if I press "Auto" and the "Reset" it prints

[None, 'Auto', 'Auto', 'Reset', 'Reset']

instead of

[None, 'Auto', 'Reset']

Is it expected ?

edit retag flag offensive close merge delete

Comments

I would say 'no'. Note that when you re-click on the same button, it is only appended once.

tmonteil gravatar imagetmonteil ( 2019-10-14 22:34:55 +0100 )edit

Hello. I experimented with your code and didn't experience that curious behavior. Could you check your mouse configuration and/or use only the keyboard to move from button to button and press them?

Do you have additional code in the same Cell?

dsejas gravatar imagedsejas ( 2019-10-15 00:24:57 +0100 )edit

@dsejas

I got the same result using @Hivert code with numeric keypad Touch 5 for simulating mouse click. On Which OS and Sagemath Version are you dsejas ?

mouse-click-with-keyboard

see also this related post

ortollj gravatar imageortollj ( 2020-03-23 13:37:44 +0100 )edit

Hello, @ortollj! I don't remember what version of Sage I was using when I tried to @Hivert's code. However---this is odd!---, I just tried to execute it again in SageMath 9.0, in Ubuntu 18.04, and I have to say that now I can reproduce the behavior. So, maybe this is a bug (?).

As a consequence, I have upvoted the question.

dsejas gravatar imagedsejas ( 2020-03-25 19:16:53 +0100 )edit