Skip to content

Instantly share code, notes, and snippets.

box_layout = widgets.Layout(
border='solid 1px red',
margin='0px 10px 10px 0px',
padding='5px 5px 5px 5px')
vbox1, vbox2 = make_boxes()
vbox1.layout = box_layout
vbox2.layout = box_layout
def make_boxes():
vbox1 = widgets.VBox([widgets.Label('Left'), b1, b2])
vbox2 = widgets.VBox([widgets.Label('Right'), dropdown, radiobuttons])
return vbox1, vbox2
vbox1, vbox2 = make_boxes()
widgets.HBox([vbox1, vbox2])
widgets.VBox([b1, b2, b3])
widgets.HBox([b1, b2, b3])
b1 = widgets.Button(description='button 1')
b2 = widgets.Button(description='button 2')
b3 = widgets.Button(description='button 3')
sl1 = widgets.IntSlider(description='slider 1', min=0, max=10)
sl2 = widgets.IntSlider(description='slider 2', min=0, max=10)
link = widgets.link(
(sl1, 'value'),
(sl2, 'min')
)
sl1.value = 5
widgets.VBox([sl1, sl2])
def show_change(change):
display(change)
int_slider = widgets.IntSlider(value=7, min=0, max=10)
int_slider.observe(show_change, 'value')
int_slider.value = 6
x = np.linspace(0, 2 * np.pi, 100)
fig, ax = plt.subplots()
line, = ax.plot(x, np.sin(x))
ax.grid(True)
def update(change):
line.set_ydata(np.sin(change.new * x))
fig.canvas.draw()
int_slider = widgets.IntSlider(
value=5,
min=0, max=10, step=1,
description='slider'
)
int_range_slider = widgets.IntRangeSlider(
value=(20, 40),
min=0, max=100, step=2,
description='range slider'
label = widgets.Label(
value='A label')
html = widgets.HTML(
value='<b>Formatted</b> <font color="red">html</font>',
description=''
)
text = widgets.Text(
value='A text field',