question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing options of Select widget triggers Callback

See original GitHub issue

@jasongrout we should have a way to change the options of a Select widget without triggering the callback function. Whenever the options are changed for the widget the value attribute is automatically set which forces the callback to be triggered. See code below;

from ipywidgets import Select

# callback
def cb(change):
    print(change)

# widget
s_w = Select(value=None, options=['a','b'])
s_w.observe(cb, names='value')

# triggers no callback
s_w.value = None
# triggers callback
s_w.options = ['1', '2', '3']

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
nickpollaricommented, Apr 2, 2019

@crahan my workaround has been to utilize the .unobserve method before updating the options.

s_w.unobserve(cb, 'value')
s_w.options = ['1','2','3']
s_w.observe(cb, 'value')
0reactions
martinRenoucommented, Sep 20, 2021

Should fix #3284

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger event when the select is changed - Stack Overflow
Triggered when the selected item has changed. Not every select event will fire a change event. select( event, ui ) Type: selectmenuselect.
Read more >
How can I change the options of a Select field (bokeh serve)?
My project has two select fields. The first selection generates a list, which I want show in the second selection. The callback works...
Read more >
Selectmenu Widget | jQuery UI API Documentation
change ( event, ui )Type: selectmenuchange. Triggered when the selected item has changed. Not every select event will fire a change event.
Read more >
change - API Reference - Kendo UI DropDownList
Fired when the value of the widget is changed by the user. As of 2015 Q3 SP1 cascading widget will trigger change event...
Read more >
Editing Resources and Callbacks in PhAB
The previously selected option is deselected. Apply your changes. The widget changes to reflect the new option. For a description of the standard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found