我试图临时更改ipywidgets.ToggleButtons列表中按钮的颜色,但是我无法访问ToggleButtons实例中的各个元素。
因此,我缺少一种def get_child_of()
功能
from IPython.display import display
import ipywidgets as widgets
# Create ToggleButtons
class_buttons = widgets.ToggleButtons(
options=['blender', 'boiling-water', 'book'],
description='Classes:')
# Create clickable Button
next_button = widgets.Button(
description='Next')
@next_button.on_click
def next_audio(b):
# TODO: Somehow get the desired child
child = get_child_of(class_buttons, 'blender')
child.style.button_color = 'lightgreen'
# Create VBox
tab = widgets.VBox(children=[class_buttons,
next_button])
# Display everything
display(tab)