ipywidget Combobox widget got triggered as typing

Viewed 136

I am using Combobox widget and have that widget observe on a give function call. However the issue I ran into, is as I/user type the "input" in the combobox, the function got called multiple times. Ideally I would only want the Observe function be called after I complete the input and press "enter".

Here is an example:

example_widget = widgets.Combobox( options = ['A','A1','A10','A101'], 
ensure_option = True, description ='Example')

and here is the observe; call back

example_widget.observe(foo, 'value')
def foo(,_):
    print('call back got triggered')

so as one type "A10" progressively, the call back was triggered three times, namely as A, A1, A10 were typed.

The ideal behaviour is that I input A10, and then press "enter", the call back function foo() only got executed once.

Thanks

enter image description here

1 Answers
example_widget = widgets.Combobox( options = ['A','A1','A10','A101'], 
ensure_option = True, description ='Example', continuous_update = False)

need to set continuous_update to False.

Related