Update section on embed ipywidgets
In the current example, single_widget is only a class attribute, such that when creating a new instance of MyComponent, the same widget is displayed. The user rather would rather need to have a different instance of single_widget for each instance of MyComponent.
For that, I suggest to initialise the embedded ipywidget of MyComponent within the __init__ function. This also gives the possibility of customising the embedded widget upon instantiating MyComponent, via keyword arguments given to the _init__ function.
The patch also harmonises quote style used in the code example.
Thanks for your contribution, sorry for the delayed response.
Maybe it's a bit simpler for this example to just set the content when creating MyComponent (also applied to the other 2 widgets):
...
items = traitlets.List().tag(sync=True, **widgets.widget_serialization)
single_widget = traitlets.Any().tag(sync=True, **widgets.widget_serialization)
...
MyComponent(
items=[{
'title': 'Title 1',
'content': slider1
}, {
'title': 'Title 2',
'content': slider2
}],
single_widget=widgets.IntSlider(description='Single slider', value=40)
)
I agree with your suggestion. Shall I update the commit or do you prefer to do it?
It would be great if you could do it!
Thanks @guimillet!