I have some code in a cell in Jupyter notebook using both a radio button and a slider. I have a method which I want called only when the selection is changed (in the case of the radio button); and only when the slider is released (in the case of the slider).
However, using the 'observe' method is triggering multiple times when a radio button is only changed once (it fires 3 times I believe). And the slider observe method fires when the mouse-down and mouse-up occurs.
Can this be changed so that it only is called once or do I need to use something other than observe?
[EDIT] Here is updated example using a radio button along with the output printed when an option is selected once:
import ipywidgets as widgets
def radio_called(sender):
print('radio_called')
print(sender)
radio = widgets.RadioButtons(options=['option 1', 'option2', 'option3'])
radio.observe(radio_called)
display(radio)
Printed output when an option is clicked once: radio_called
{'name': '_property_lock', 'old': traitlets.Undefined, 'new': {'index': 1}, 'owner': RadioButtons(options=('option 1', 'option2', 'option3'), value='option 1'), 'type': 'change'}
radio_called
{'name': 'label', 'old': 'option 1', 'new': 'option2', 'owner': RadioButtons(index=1, options=('option 1', 'option2', 'option3'), value='option 1'), 'type': 'change'}
radio_called
{'name': 'value', 'old': 'option 1', 'new': 'option2', 'owner': RadioButtons(index=1, options=('option 1', 'option2', 'option3'), value='option2'), 'type': 'change'}
radio_called
{'name': 'index', 'old': 0, 'new': 1, 'owner': RadioButtons(index=1, options=('option 1', 'option2', 'option3'), value='option2'), 'type': 'change'}
radio_called
{'name': '_property_lock', 'old': {'index': 1}, 'new': {}, 'owner': RadioButtons(index=1, options=('option 1', 'option2', 'option3'), value='option2'), 'type': 'change'}