Widget List.ipynb
578 lines
| 11.8 KiB
| text/plain
|
TextLexer
Jonathan Frederic
|
r17489 | { | |
"metadata": { | |||
Jonathan Frederic
|
r17509 | "celltoolbar": "Slideshow", | |
Jonathan Frederic
|
r17489 | "name": "", | |
Jonathan Frederic
|
r17515 | "signature": "sha256:f8284581eb29fde72c434a9a414fcb60837302177ebaa4af6ff219dd2b726381" | |
Jonathan Frederic
|
r17489 | }, | |
"nbformat": 3, | |||
"nbformat_minor": 0, | |||
"worksheets": [ | |||
{ | |||
"cells": [ | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17501 | "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)" | |
] | |||
}, | |||
{ | |||
Jonathan Frederic
|
r17510 | "cell_type": "heading", | |
"level": 1, | |||
Jonathan Frederic
|
r17501 | "metadata": {}, | |
Jonathan Frederic
|
r17510 | "source": [ | |
"Widget List" | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
"metadata": {}, | |||
"source": [ | |||
"Complete list" | |||
] | |||
Jonathan Frederic
|
r17509 | }, | |
{ | |||
"cell_type": "markdown", | |||
"metadata": { | |||
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17501 | "source": [ | |
Jonathan Frederic
|
r17489 | "For a complete list of the widgets available to you, you can list the classes in the widget namespace (as seen below). Classes with the suffix `Widget` are widgets. `Widget` and `DOMWidget` are base classes." | |
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"from IPython.html import widgets\n", | |||
"[w for w in dir(widgets) if w.endswith('Widget')]" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"Numeric widgets" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17501 | "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." | |
Jonathan Frederic
|
r17489 | ] | |
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"FloatSliderWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.FloatSliderWidget(\n", | |||
" value=7.5,\n", | |||
" min=5.0,\n", | |||
" max=10.0,\n", | |||
" step=0.1,\n", | |||
" description='Test:',\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17509 | "Sliders can also be **displayed vertically**." | |
Jonathan Frederic
|
r17489 | ] | |
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.FloatSliderWidget(\n", | |||
" value=7.5,\n", | |||
" min=5.0,\n", | |||
" max=10.0,\n", | |||
" step=0.1,\n", | |||
" description='Test',\n", | |||
" orientation='vertical',\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"FloatProgressWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.FloatProgressWidget(\n", | |||
" value=7.5,\n", | |||
" min=5.0,\n", | |||
" max=10.0,\n", | |||
" step=0.1,\n", | |||
" description='Loading:',\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"BoundedFloatTextWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.BoundedFloatTextWidget(\n", | |||
" value=7.5,\n", | |||
" min=5.0,\n", | |||
" max=10.0,\n", | |||
" description='Text:',\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"FloatTextWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.FloatTextWidget(\n", | |||
" value=7.5,\n", | |||
" description='Any:',\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"Boolean widgets" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"There are two widgets that are designed to display a boolean value." | |||
] | |||
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
"metadata": {}, | |||
"source": [ | |||
"ToggleButtonWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.ToggleButtonWidget(\n", | |||
" description='Click me',\n", | |||
" value=False,\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"CheckboxWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.CheckboxWidget(\n", | |||
" description='Check me',\n", | |||
" value=True,\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"Selection widgets" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17509 | "There are four widgets that can be used to display single selection lists. All four inherit from the same base class. You can specify the **enumeration of selectables 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." | |
Jonathan Frederic
|
r17489 | ] | |
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"DropdownWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"from IPython.display import display\n", | |||
"w = widgets.DropdownWidget(\n", | |||
" values=[1, 2, 3],\n", | |||
" value=2,\n", | |||
" description='Number:',\n", | |||
")\n", | |||
"display(w)" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"w.value" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"The following is also valid:" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"w = widgets.DropdownWidget(\n", | |||
" values={'One': 1, 'Two': 2, 'Three': 3},\n", | |||
" value=2,\n", | |||
" description='Number:',\n", | |||
")\n", | |||
"display(w)" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"w.value" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"RadioButtonsWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.RadioButtonsWidget(\n", | |||
" description='Pizza topping:',\n", | |||
" values=['pepperoni', 'pineapple', 'anchovies'],\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"SelectWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.SelectWidget(\n", | |||
" description='OS:',\n", | |||
" values=['Linux', 'Windows', 'OSX'],\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"ToggleButtonsWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.ToggleButtonsWidget(\n", | |||
" description='Speed:',\n", | |||
" values=['Slow', 'Regular', 'Fast'],\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"String widgets" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17509 | "There are 4 widgets that can be used to display a string value. Of those, the **`TextWidget` and `TextareaWidget` accept input**. The **`LatexWidget` and `HTMLWidget` display the string** as either Latex or HTML respectively, but **do not accept input**." | |
Jonathan Frederic
|
r17489 | ] | |
}, | |||
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"TextWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.TextWidget(\n", | |||
" description='String:',\n", | |||
Jonathan Frederic
|
r17501 | " value='Hello World',\n", | |
Jonathan Frederic
|
r17489 | ")" | |
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
"metadata": {}, | |||
"source": [ | |||
"TextareaWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.TextareaWidget(\n", | |||
" description='String:',\n", | |||
Jonathan Frederic
|
r17501 | " value='Hello World',\n", | |
Jonathan Frederic
|
r17489 | ")" | |
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"LatexWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.LatexWidget(\n", | |||
" value=\"$$\\\\frac{n!}{k!(n-k)!} = \\\\binom{n}{k}$$\",\n", | |||
")" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 3, | |||
"metadata": {}, | |||
"source": [ | |||
"HTMLWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.HTMLWidget(\n", | |||
Jonathan Frederic
|
r17501 | " value=\"Hello <b>World</b>\"\n", | |
Jonathan Frederic
|
r17489 | ")" | |
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "heading", | |||
"level": 2, | |||
Jonathan Frederic
|
r17509 | "metadata": { | |
"slideshow": { | |||
"slide_type": "slide" | |||
} | |||
}, | |||
Jonathan Frederic
|
r17489 | "source": [ | |
"ButtonWidget" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
"collapsed": false, | |||
"input": [ | |||
"widgets.ButtonWidget(description='Click me')" | |||
], | |||
"language": "python", | |||
"metadata": {}, | |||
Jonathan Frederic
|
r17515 | "outputs": [] | |
Jonathan Frederic
|
r17489 | }, | |
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
Jonathan Frederic
|
r17501 | "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)" | |
Jonathan Frederic
|
r17489 | ] | |
} | |||
], | |||
"metadata": {} | |||
} | |||
] | |||
} |