Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "nbsphinx": "hidden"
- },
- "source": [
- "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Widget List"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "import ipywidgets as widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "## Numeric widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "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": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### IntSlider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "f671d78f3b45471897b95005bca26d2e"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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='i',\n",
- " slider_color='white'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### FloatSlider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "05884679cab24894bf3385aae860b4f7"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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",
- " slider_color='white'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "Sliders can also be **displayed vertically**."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "1b1cc4fdd79b43419eeb8d5bea8947c9"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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",
- " slider_color='white'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### IntRangeSlider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "b59a05d7be7143a3b72dee5558ff7ae9"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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='i',\n",
- " slider_color='white',\n",
- " color='black'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### FloatRangeSlider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "26faef9a3dcb474986e390e3d3e86b28"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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='i',\n",
- " slider_color='white',\n",
- " color='black'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### IntProgress"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "d9f72952e04645d09441a73997d6cbfd"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.IntProgress(\n",
- " value=7,\n",
- " min=0,\n",
- " max=10,\n",
- " step=1,\n",
- " description='Loading:',\n",
- " bar_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
- " orientation='horizontal'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### FloatProgress"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "af354e202b474fe7ba7cf8a50b93a774"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.FloatProgress(\n",
- " value=7.5,\n",
- " min=0,\n",
- " max=10.0,\n",
- " step=0.1,\n",
- " description='Loading:',\n",
- " bar_style='info',\n",
- " orientation='horizontal'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### BoundedIntText"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "5f7c6372417f4f1e968142734c6f32b4"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### BoundedFloatText"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "69923ecdd06448ee837a7c1485b1b3e6"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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",
- " color='black'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### IntText"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "0f637a3374f447cb8ba705c684bca651"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.IntText(\n",
- " value=7,\n",
- " description='Any:',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### FloatText"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "289249d445584d0485fab77cab5e6d8c"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.FloatText(\n",
- " value=7.5,\n",
- " description='Any:',\n",
- " disabled=False,\n",
- " color='black'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "## Boolean widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "There are three widgets that are designed to display a boolean value."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### ToggleButton"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "7ec95ca7e180480abdaf463e6a5b7995"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "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'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### Checkbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "424a123f70cc4a338d70ea0210174bf5"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Checkbox(\n",
- " value=False,\n",
- " description='Check me',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### Valid\n",
- "\n",
- "The valid widget provides a read-only indicator."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "855a9f9a102f451282a96f8970777653"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Valid(\n",
- " value=False,\n",
- " description='Valid!',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "## Selection widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "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."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### Dropdown"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "f5e5738f320c4924bfd6088c0cf88298"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Dropdown(\n",
- " options=['1', '2', '3'],\n",
- " value='2',\n",
- " description='Number:',\n",
- " disabled=False,\n",
- " button_style='' # 'success', 'info', 'warning', 'danger' or ''\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "The following is also valid:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "16a1d0cdfbab4fc48098b2aedc8a5fba"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Dropdown(\n",
- " options={'One': 1, 'Two': 2, 'Three': 3},\n",
- " value=2,\n",
- " description='Number:',\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### RadioButtons"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "33e2d8d3d05f4d25a4f9548ed28f4f53"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.RadioButtons(\n",
- " options=['pepperoni', 'pineapple', 'anchovies'],\n",
- "# value='pineapple',\n",
- " description='Pizza topping:',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### Select"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "cc9e93944d1c4ff8938ada91aa1ddfbb"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Select(\n",
- " options=['Linux', 'Windows', 'OSX'],\n",
- " value='OSX',\n",
- " # rows=10,\n",
- " description='OS:',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### SelectionSlider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e7e7f33aa07d47fc8abf366ae0ff665d"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.SelectionSlider(\n",
- " options=['scrambled', 'sunny side up', 'poached', 'over easy'],\n",
- " value='sunny side up',\n",
- " description='I like my eggs ...',\n",
- " disabled=False,\n",
- " continuous_update=False,\n",
- " orientation='horizontal',\n",
- " readout=True,\n",
- "# readout_format='i',\n",
- "# slider_color='black'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### ToggleButtons"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "f6d2eb53cd5f41b0a9a1d78ef75d00dc"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.ToggleButtons(\n",
- " options=['Slow', 'Regular', 'Fast'],\n",
- " description='Speed:',\n",
- " disabled=False,\n",
- " button_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
- " tooltip='Description',\n",
- "# icon='check' \n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### SelectMultiple\n",
- "Multiple values can be selected with <kbd>shift</kbd> and/or <kbd>ctrl</kbd> (or <kbd>command</kbd>) pressed and mouse clicks or arrow keys."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "73a7d540f0354193a7a633bf821034bc"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.SelectMultiple(\n",
- " options=['Apples', 'Oranges', 'Pears'],\n",
- " value=['Oranges'],\n",
- " #rows=10,\n",
- " description='Fruits',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "## String widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "There are 4 widgets that can be used to display a string value. Of those, the `Text` and `Textarea` widgets accept input. The `Label` and `HTML` widgets display the string as either Label or HTML respectively, but do not accept input."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### Text"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 23,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "bc0e616ad9d94daea4166ad6084b4b4e"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Text(\n",
- " value='Hello World',\n",
- " placeholder='Type something',\n",
- " description='String:',\n",
- " disabled=False \n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### Textarea"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "287f1c3470db4ac0b0155c59d264a262"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Textarea(\n",
- " value='Hello World',\n",
- " placeholder='Type something',\n",
- " description='String:',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "### Label"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 25,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "5d2e66fd063848bfb122d37a2c3abe23"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Label(\n",
- " value=\"$$\\\\frac{n!}{k!(n-k)!} = \\\\binom{n}{k}$$\",\n",
- " placeholder='Some LaTeX',\n",
- " description='Some LaTeX',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## HTML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "a12ebc5e47ea48a0a4235ad4ffd04a84"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.HTML(\n",
- " value=\"Hello <b>World</b>\",\n",
- " placeholder='Some HTML',\n",
- " description='Some HTML',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## HTML Math"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "a929a41a5b874d549515a489b103bc0d"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.HTMLMath(\n",
- " value=r\"Some math and <i>HTML</i>: $x^2$ and $$\\frac{x+1}{x-1}$$\",\n",
- " placeholder='Some HTML',\n",
- " description='Some HTML',\n",
- " disabled=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Image"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "0bbef2ecf82647e6b5ec5e3aea21ef98"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "file = open(\"images/WidgetArch.png\", \"rb\")\n",
- "image = file.read()\n",
- "widgets.Image(\n",
- " value=image,\n",
- " format='png',\n",
- " width=300,\n",
- " height=400\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "## Button"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 29,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "26d781d848774f2d9495ed169a6b8524"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Button(\n",
- " description='Click me',\n",
- " disabled=False,\n",
- " button_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
- " tooltip='Click me',\n",
- " icon='check'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Play (Animation) widget"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "The `Play` widget is useful to perform animations by iterating on a sequence of integers with a certain speed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 30,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "92991d50fb09447f8777d9115d9b883e"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "play = widgets.Play(\n",
- "# interval=10,\n",
- " value=50,\n",
- " min=0,\n",
- " max=100,\n",
- " step=1,\n",
- " description=\"Press play\",\n",
- " disabled=False\n",
- ")\n",
- "slider = widgets.IntSlider()\n",
- "widgets.jslink((play, 'value'), (slider, 'value'))\n",
- "widgets.HBox([play, slider])"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Date picker\n",
- "\n",
- "The date picker widget works in Chrome and IE Edge, but does not currently work in Firefox or Safari because they do not support the HTML date input field."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 31,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "d73b4c80339149a5bc0fd826283cb1f2"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.DatePicker(\n",
- " description='Pick a Date'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Color picker"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 32,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "f44927d934c84abb85879392757064f2"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.ColorPicker(\n",
- " concise=False,\n",
- " description='Pick a color',\n",
- " value='blue'\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Controller"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 33,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "da89da0a882a439d92257c9b96bffcf8"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "widgets.Controller(\n",
- " index=0,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## Layout widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### Box"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### HBox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 34,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "9dc5447b40d44577b1df0f324af2fcfa"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "items = [widgets.Label(str(i)) for i in range(4)]\n",
- "widgets.HBox(items)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### VBox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 35,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e2e1ea388a8a441696515197883c29ad"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "items = [widgets.Label(str(i)) for i in range(4)]\n",
- "widgets.HBox([widgets.VBox([items[0], items[1]]), widgets.VBox([items[2], items[3]])])"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### Accordion"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 36,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "de216851eb254d8e82a3e9005916de59"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "accordion = widgets.Accordion(children=[widgets.IntSlider(), widgets.Text()])\n",
- "accordion.set_title(0, 'Slider')\n",
- "accordion.set_title(1, 'Text')\n",
- "accordion"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### Tabs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 37,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "64ab0f19ae97452386c76e19291cc8e4"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "list = ['P0', 'P1', 'P2', 'P3', 'P4']\n",
- "children = [widgets.Text(description=name) for name in list]\n",
- "tab = widgets.Tab(children=children)\n",
- "tab"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true,
- "nbsphinx": "hidden"
- },
- "source": [
- "[Index](Index.ipynb) - [Back](Widget Basics.ipynb) - [Next](Widget Events.ipynb)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python [default]",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.5.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement