from IPython.display import display button = widgets.Button(description="Click Me!") output = widgets.Output() display(button, output) def on_button_clicked(b): with output: output.clear_output() print("Button clicked.") button.on_click(on_button_clicked)
int_range = widgets.IntSlider() output2 = widgets.Output() display(int_range, output2) def on_value_change(change): with output2: output2.clear_output() print(change['new']) # tigger callback when traits in the names are changed int_range.observe(on_value_change, names=['value'], type='change')