Algoteka
Log in to submit your own samples!

Update Cell with a Dropdown Widget

Problem by oml1111
# Tech tags Title Creator Created date
1 0
ipywidgets
Jupyter
2023-01-29 22:03
View all samples for this language (1 verified and 0 unverified)

Using interact, automatic update | Python | ipywidgets Jupyter |

By oml1111 |
0 likes

Creates a dropdown widget using the @interact decorator and prints a value based on the choice in that widget. The cell is automatically recomputed when a new value is chosen.

Code

[1]:

from ipywidgets import interact

[2]:

@interact(x=['Alice', 'Bob', 'Caroline'])
def function(x):
    print("Hello", x)

Further reading

Using Interact - ipywidgets.readthedocs.io

References

functions
interact ipywidgets.readthedocs.io github.com
print docs.python.org

Problem Description

Create a dropdown widget in your notebook and make it so that the output of a cell is recomputed based on the chosen value in the widget

View sample discussion (0 comments)
View problem discussion (0 comments)