jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.16k stars 951 forks source link

Select broken in 6.0.0b2 #876

Closed justinmc closed 7 years ago

justinmc commented 7 years ago

Not sure if you guys are already aware of bugginess in Select in the beta releases, but I tried upgrading and noticed Selects weren't working so thought I'd submit this. Setting value on a Select seems to be broken in 6.0.0b1 and b2.

import ipywidgets
from IPython.display import display
select = ipywidgets.Select(
     options={'ok': 'ok', 'yes': 'yes', 'maybe': 'maybe', 'whatevs': 'whatevs'},
     width='100px',
     height='20px'
)
select.value = 'ok'
display(select)

The select shows up as blank (None selected) regardless of what I do programmatically. Also, observing value does not call the given function when manually changing the selected option.

jasongrout commented 7 years ago

Thanks for lettings us know. I've confirmed the issue. Investigating...

jasongrout commented 7 years ago

It looks like this commit didn't fix all the places where selected_label was used: https://github.com/ipython/ipywidgets/commit/aef3069a3b965bd675d983fa3952aec2c2067620

Edit: Nope, that's not it. Still looking...

jasongrout commented 7 years ago

Looks like it might have @afshin's commit: https://github.com/ipython/ipywidgets/commit/5b47aaac9285ec961e43525cc1dea2e9047b7edd#diff-61326cb05eb256df11c903abf2527196R605 - that's where it is switched from using the model's value attribute to a selected_label attribute, though it doesn't appear that such an attribute exists on the model.

jasongrout commented 7 years ago

Of course, we should have caught that on review of @afshin's PR too.

afshin commented 7 years ago

D'oh! I missed that; mea culpa.

:sweat_smile:

SylvainCorlay commented 7 years ago

@afshin actually, the change from selected_item to value happened around the same time as your PR, so it is almost certainly a rebase thing 😄 .