有没有办法强制 Accordion 小部件视图在笔记本上显示后刷新/更改标题?
import ipywidgets as widgets
accordion = widgets.Accordion()
numbers = widgets.Dropdown(options=['1', '2'], value='1')
accordion.children = [numbers]
accordion.set_title(0, 'current value: ' + numbers.value)
def set_title(change):
display(accordion.get_title(0)) # DEBUG: this shows prover value, however the view doesn't refresh the title
accordion.set_title(0, 'current value: ' + change.new)
numbers.observe(set_title, names='value')
display(accordion)
# after displaying, this also doesn't work
accordion.set_title(0, 'current value: whatever')