import ipywidgets as widgets
w = widgets.FileUpload(
accept='', # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'
multiple=False # True to accept multiple files upload else False
)
display(w)
uploaded_file = list(w.value.values())[0]
content = uploaded_file['content']
name = uploaded_file['metadata']['name']
fp = open(name, 'wb')
fp.write(content)
37325
button = widgets.Button(description='Click me',)
dropdown = widgets.Dropdown(options=['1', '2', '3'],)
widgets.Box([button, dropdown])
#link
caption = widgets.Label(value='The values of slider1 and slider2 are synchronized')
sliders1, slider2 = widgets.IntSlider(description='Slider 1'),\
widgets.IntSlider(description='Slider 2')
l = widgets.link((sliders1, 'value'), (slider2, 'value'))
display(caption, sliders1, slider2)
#dlink
caption = widgets.Label(value='Changes in source values are reflected in target1')
source, target1 = widgets.IntSlider(description='Source'),\
widgets.IntSlider(description='Target 1')
dl = widgets.dlink((source, 'value'), (target1, 'value'))
display(caption, source, target1)
#jslink
a = widgets.FloatText()
b = widgets.FloatSlider()
display(a,b)
mylink = widgets.jslink((a, 'value'), (b, 'value'))
# Continuous updates
a = widgets.IntSlider(description="1", continuous_update=False)
b = widgets.IntText(description="2", continuous_update=False)
c = widgets.IntSlider(description="3", continuous_update=True)
d = widgets.IntText(description="4", continuous_update=True)
widgets.link((a, 'value'), (b, 'value'))
widgets.link((b, 'value'), (c, 'value'))
widgets.link((c, 'value'), (d, 'value'))
widgets.VBox([a,b,c,d])