I need to create a variable number of widgets and then identify which widget is being observed when the user interacts with one of them. In the following example, n IntSliders are being created:
import ipywidgets as wg
def obs(change):
print(change)
def fun(n):
l = []
for i in range(n):
l.append(wg.IntSlider())
l[i].observe(obs, names='value')
display(wg.VBox(l))
fun(4)
When interacting with one of the sliders, the change variable only gives the values for owner, old, new, type and name.
{'owner': IntSlider(value=1), 'new': 1, 'old': 0, 'type': 'change', 'name': 'value'}
I would like to "tweak" the content of change to include its position in the list l.
Note: I cannot use existing IntSlider attributes like description because then it will be reflected in the widget appearance.