def __init__(self, *args, **kwargs):
self._select = Dropdown(*args,**kwargs)
self._edit = Button(description='...',
layout=Layout(width='15px'))
self._composite = HBox([self._select,self._edit])
super(DropdownWithEdit, self).__init__()
self.layout = self._composite.layout
# so that others looking at this widget's value get the
# dropdown's value
traitlets.link((self._select,'value'),(self,'value'))
self._edit.on_click(lambda _: editor(self._select.value))
self._select.observe(lambda e: self._set_editable(e['new']),'value')
self._set_editable(self._select.value)
评论列表
文章目录