{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Output Widget.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Widget List" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipywidgets as widgets" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Numeric widgets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are many widgets distributed with ipywidgets that are designed to display numeric values. Widgets exist for displaying integers and floats, both bounded and unbounded. The integer widgets share a similar naming scheme to their floating point counterparts. By replacing `Float` with `Int` in the widget name, you can find the Integer equivalent." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IntSlider \n", "- The slider is displayed with a specified, initial `value`. Lower and upper bounds are defined by `min` and `max`, and the value can be incremented according to the `step` parameter.\n", "- The slider's label is defined by `description` parameter \n", "- The slider's `orientation` is either 'horizontal' (default) or 'vertical'\n", "- `readout` displays the current value of the slider next to it. The options are **True** (default) or **False** \n", " - `readout_format` specifies the format function used to represent slider value. The default is '.2f'\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.IntSlider(\n", " value=7,\n", " min=0,\n", " max=10,\n", " step=1,\n", " description='Test:',\n", " disabled=False,\n", " continuous_update=False,\n", " orientation='horizontal',\n", " readout=True,\n", " readout_format='d'\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### FloatSlider " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatSlider(\n", " value=7.5,\n", " min=0,\n", " max=10.0,\n", " step=0.1,\n", " description='Test:',\n", " disabled=False,\n", " continuous_update=False,\n", " orientation='horizontal',\n", " readout=True,\n", " readout_format='.1f',\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "An example of sliders **displayed vertically**." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatSlider(\n", " value=7.5,\n", " min=0,\n", " max=10.0,\n", " step=0.1,\n", " description='Test:',\n", " disabled=False,\n", " continuous_update=False,\n", " orientation='vertical',\n", " readout=True,\n", " readout_format='.1f',\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### FloatLogSlider" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `FloatLogSlider` has a log scale, which makes it easy to have a slider that covers a wide range of positive magnitudes. The `min` and `max` refer to the minimum and maximum exponents of the `base`, and the `value` refers to the actual value of the slider." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatLogSlider(\n", " value=10,\n", " base=10,\n", " min=-10, # max exponent of base\n", " max=10, # min exponent of base\n", " step=0.2, # exponent step\n", " description='Log Slider'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IntRangeSlider" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.IntRangeSlider(\n", " value=[5, 7],\n", " min=0,\n", " max=10,\n", " step=1,\n", " description='Test:',\n", " disabled=False,\n", " continuous_update=False,\n", " orientation='horizontal',\n", " readout=True,\n", " readout_format='d',\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### FloatRangeSlider" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatRangeSlider(\n", " value=[5, 7.5],\n", " min=0,\n", " max=10.0,\n", " step=0.1,\n", " description='Test:',\n", " disabled=False,\n", " continuous_update=False,\n", " orientation='horizontal',\n", " readout=True,\n", " readout_format='.1f',\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IntProgress" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.IntProgress(\n", " value=7,\n", " min=0,\n", " max=10,\n", " description='Loading:',\n", " bar_style='', # 'success', 'info', 'warning', 'danger' or ''\n", " style={'bar_color': 'maroon'},\n", " orientation='horizontal'\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### FloatProgress" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatProgress(\n", " value=7.5,\n", " min=0,\n", " max=10.0,\n", " description='Loading:',\n", " bar_style='info',\n", " style={'bar_color': '#ffff00'},\n", " orientation='horizontal'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The numerical text boxes that impose some limit on the data (range, integer-only) impose that restriction when the user presses enter.\n", "\n", "### BoundedIntText" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.BoundedIntText(\n", " value=7,\n", " min=0,\n", " max=10,\n", " step=1,\n", " description='Text:',\n", " disabled=False\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### BoundedFloatText" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.BoundedFloatText(\n", " value=7.5,\n", " min=0,\n", " max=10.0,\n", " step=0.1,\n", " description='Text:',\n", " disabled=False\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IntText" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.IntText(\n", " value=7,\n", " description='Any:',\n", " disabled=False\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### FloatText" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.FloatText(\n", " value=7.5,\n", " description='Any:',\n", " disabled=False\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Boolean widgets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are three widgets that are designed to display a boolean value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ToggleButton" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.ToggleButton(\n", " value=False,\n", " description='Click me',\n", " disabled=False,\n", " button_style='', # 'success', 'info', 'warning', 'danger' or ''\n", " tooltip='Description',\n", " icon='check' # (FontAwesome names without the `fa-` prefix)\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Checkbox \n", "- `value` specifies the value of the checkbox\n", "- `indent` parameter places an indented checkbox, aligned with other controls. Options are **True** (default) or **False** \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.Checkbox(\n", " value=False,\n", " description='Check me',\n", " disabled=False,\n", " indent=False\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Valid\n", "\n", "The valid widget provides a read-only indicator." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "widgets.Valid(\n", " value=False,\n", " description='Valid!',\n", ")" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Selection widgets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are several widgets that can be used to display single selection lists, and two that can be used to select multiple values. All inherit from the same base class. You can specify the **enumeration of selectable options by passing a list** (options are either (label, value) pairs, or simply values for which the labels are derived by calling `str`).\n", "\n", "