如何访问个人风格的ToggleButtons?

时间:2019-03-26 09:14:09

标签: python jupyter-notebook ipywidgets

我试图临时更改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)

0 个答案:

没有答案