Welcome to Raspbot V2 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
10. Basic use of Jupyter Widgets
Basic use of Jupyter Widgets
Basic use of Jupyter Widgets1. Use Widgets2. Use of widgetsButtonSliderText boxCheckboxDrop-down menuProgress barEffect demonstration
Jupyter Widgets is an interactive tool that can be used to create dynamic and interactive user interfaces in Jupyter lab; it can be used to build various widgets, such as buttons, sliders, text boxes, etc., so that users can interact in Jupyter lab.
1. Use Widgets
Import the Jupyter Widgets library and add the following content to the Jupyter lab code block:
import ipywidgets as widgets
2. Use of widgets
Button
Used to trigger specific actions or events, such as clicking a button to execute specific code.
ximport ipywidgets as widgetsfrom IPython.display import displaybutton = widgets.Button(description="Click me")display(button)def on_button_clicked(b):print("Button clicked")button.on_click(on_button_clicked)
Slider
Used to select a value by dragging.
xxxxxxxxxxslider = widgets.IntSlider(value=5, min=0, max=10, step=1)display(slider)def handle_slider_change(change):print("Slider value:", change.new)slider.observe(handle_slider_change, names='value')
Text box
Used to enter text data.
xxxxxxxxxxtext = widgets.Text(value="HelloWorld", description="Input:")display(text)def handle_text_change(change):print("Text value:", change.new)text.observe(handle_text_change, names='value')
Checkbox
Used to switch selection.