How to create buttons in Jupyter?
In this article, we will learn How to create an interactive button in Jupyter using Python Program. An Interactive Button is a button which when clicked by a user performs a specific function. For the following task, we need the ipywidgets library module. ipywidgets, also known as jupyter-widgets or simply widgets, are interactive HTML widgets for Jupyter notebooks and the IPython kernel.
If your console does not have the module, you can install it by using the following command:
pip install ipywidgets
In most cases, installing the Python ipywidgets package will also automatically configure classic Jupyter Notebook and JupyterLab 3.0 to display ipywidgets.
Example 1: Creating a simple button.
Syntax: widgets.Button(description=’My Button’)
Here, we will create an interactive button that will help us to select a random language from a list of given Languages.
- interact_manual(): Automatically creates a User Interface Control for exploring code and data interactively.
- choice(): Returns a randomly selected element from the specified sequence.