##// END OF EJS Templates
Fix bugs in the accordion and tab widget styling example notebook.
Fix bugs in the accordion and tab widget styling example notebook.

File last commit:

r20541:1e566dcc
r21465:2292cfce
Show More
Widget List.ipynb
621 lines | 11.4 KiB | text/plain | TextLexer
Jonathan Frederic
Added widget list
r17489 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Widget List"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Complete list"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"For a complete list of the widgets available to you, you can list the classes in the widget namespace (as seen below). `Widget` and `DOMWidget`, not listed below, are base classes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from IPython.html import widgets\n",
"[n for n in dir(widgets) if not n.endswith('Widget') and n[0] == n[0].upper() and not n[0] == '_']"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Numeric widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are 8 widgets distributed with IPython 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": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### FloatSlider"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.FloatSlider(\n",
" value=7.5,\n",
" min=5.0,\n",
" max=10.0,\n",
" step=0.1,\n",
" description='Test:',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sliders can also be **displayed vertically**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.FloatSlider(\n",
" value=7.5,\n",
" min=5.0,\n",
" max=10.0,\n",
" step=0.1,\n",
" description='Test',\n",
" orientation='vertical',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### FloatProgress"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.FloatProgress(\n",
" value=7.5,\n",
" min=5.0,\n",
" max=10.0,\n",
" step=0.1,\n",
" description='Loading:',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### BoundedFloatText"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.BoundedFloatText(\n",
" value=7.5,\n",
" min=5.0,\n",
" max=10.0,\n",
" description='Text:',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### FloatText"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.FloatText(\n",
" value=7.5,\n",
" description='Any:',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Boolean widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two widgets that are designed to display a boolean value."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ToggleButton"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.ToggleButton(\n",
" description='Click me',\n",
" value=False,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Checkbox"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Checkbox(\n",
" description='Check me',\n",
" value=True,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Selection widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
Nicholas Bollweg
squashing the whitespace changes
r20287 "There are four widgets that can be used to display single selection lists, and one that can be used to display multiple selection lists. All inherit from the same base class. You can specify the **enumeration of selectable options by passing a list**. You can **also specify the enumeration as a dictionary**, in which case the **keys will be used as the item displayed** in the list and the corresponding **value will be returned** when an item is selected."
Min RK
upate exmaple notebooks to nbformat v4
r18669 ]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Dropdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from IPython.display import display\n",
"w = widgets.Dropdown(\n",
Nicholas Bollweg
squashing the whitespace changes
r20287 " options=['1', '2', '3'],\n",
Thomas Kluyver
Fix widget dropdown example...
r20095 " value='2',\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 " description='Number:',\n",
")\n",
"display(w)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w.value"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following is also valid:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w = widgets.Dropdown(\n",
Nicholas Bollweg
squashing the whitespace changes
r20287 " options={'One': 1, 'Two': 2, 'Three': 3},\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 " value=2,\n",
" description='Number:',\n",
")\n",
"display(w)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w.value"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### RadioButtons"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.RadioButtons(\n",
" description='Pizza topping:',\n",
Nicholas Bollweg
squashing the whitespace changes
r20287 " options=['pepperoni', 'pineapple', 'anchovies'],\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 ")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Select"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Select(\n",
" description='OS:',\n",
Nicholas Bollweg
squashing the whitespace changes
r20287 " options=['Linux', 'Windows', 'OSX'],\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 ")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### ToggleButtons"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.ToggleButtons(\n",
" description='Speed:',\n",
Nicholas Bollweg
squashing the whitespace changes
r20287 " options=['Slow', 'Regular', 'Fast'],\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 ")"
]
},
{
"cell_type": "markdown",
Nicholas Bollweg
squashing the whitespace changes
r20287 "metadata": {},
"source": [
"### SelectMultiple\n",
"Multiple values can be selected with <kbd>shift</kbd> and <kbd>ctrl</kbd> pressed and mouse clicks or arrow keys."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"w = widgets.SelectMultiple(\n",
" description=\"Fruits\",\n",
" options=['Apples', 'Oranges', 'Pears']\n",
")\n",
"display(w)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w.value"
]
},
{
"cell_type": "markdown",
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## String widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are 4 widgets that can be used to display a string value. Of those, the **`Text` and `Textarea` widgets accept input**. The **`Latex` and `HTML` widgets display the string** as either Latex or HTML respectively, but **do not accept input**."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Text"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Text(\n",
" description='String:',\n",
" value='Hello World',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Textarea"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Textarea(\n",
" description='String:',\n",
" value='Hello World',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Latex"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Latex(\n",
" value=\"$$\\\\frac{n!}{k!(n-k)!} = \\\\binom{n}{k}$$\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### HTML"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.HTML(\n",
" value=\"Hello <b>World</b>\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Button"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"widgets.Button(description='Click me')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
]
}
],
Jonathan Frederic
Added widget list
r17489 "metadata": {
Jonathan Frederic
Updated widget examples for recent changes and,...
r17726 "kernelspec": {
Min RK
add kernel metadata to example notebooks
r20278 "display_name": "Python 3",
"language": "python",
"name": "python3"
Jonathan Frederic
Updated widget examples for recent changes and,...
r17726 },
Thomas Kluyver
Fix widget dropdown example...
r20095 "language_info": {
"codemirror_mode": {
"name": "ipython",
Min RK
add kernel metadata to example notebooks
r20278 "version": 3
Thomas Kluyver
Fix widget dropdown example...
r20095 },
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
Min RK
add kernel metadata to example notebooks
r20278 "pygments_lexer": "ipython3",
Jonathan Frederic
Update examples/Interactive Widgets :troll:
r20541 "version": "3.4.0"
Thomas Kluyver
Fix widget dropdown example...
r20095 }
Jonathan Frederic
Added widget list
r17489 },
Min RK
upate exmaple notebooks to nbformat v4
r18669 "nbformat": 4,
"nbformat_minor": 0
Thomas Kluyver
Fix widget dropdown example...
r20095 }