I am not sure if this is a bug or not as I am just getting into ipywidgets. After initial creation of a dropdown widget if you assign a new set of options the view does not update.
so if I do:
import ipywidgets as ipw
opts = ['one','two','three']
dpdown = ipw.Dropdown(description='selector', options=opts)
display(dpdown)
opts.append('four')
dpdown.options = opts
display(dpdown)
I Thought that I would see view update with the 'four' option added but it doesn't. I check the options attribute and it does show the 'four' added to the list.
"Update":
I am on version 4.1.1,
Linux
IE 11 over server.
so I ran the same example code on my local windows version of Anaconda that has ipywidgets 4.1.0 and setting new options does indeed update the _options_dict, _options_values, _options_labels attributes in the Dropdown widget thus the view updates as well. However in 4.1.1 they do not.
I don't see any changes in widget_selection.py between 4.1.1 and 4.1.0
Ultimatley I am trying to keep the options available in the Dropdown synced with a dictionary.
This works for me in 5.2.2. My exact commands:
from IPython.display import display
import ipywidgets as ipw
opts = ['one','two','three']
dpdown = ipw.Dropdown(description='selector', options=opts)
display(dpdown)
This shows the dropdown with 3 options. Then in the next cell:
opts.append('four')
dpdown.options = opts
The original dropdown now updates to show 4 options.
Should be ok to close this issue?
By the way, if you're looking to sync the options in the dropdown with a dictionary, look at the traitlets library, mainly traitlets.link.
What @justinmc said ^
Just adding that you can get ipywidgets 5.x by typing
conda install -c conda-forge ipywidgets
You can also check ipywidgets.jslink for a link on the javascript side.
@drafter250 Is this issue resolved after upgrading to ipywidgets 5.x?
Yes sorry i believe it is.
On Thursday, September 29, 2016, Grant Nestor [email protected]
wrote:
@drafter250 https://github.com/drafter250 Is this issue resolved after
upgrading to ipywidgets 5.x?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ipython/ipywidgets/issues/536#issuecomment-250604109,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALNFB-WwmbruUtljDKp3uLhds5nZHIqtks5qvDWdgaJpZM4IRGJw
.