##// END OF EJS Templates
Merge pull request #5459 from jdfreder/ff_animhop...
Merge pull request #5459 from jdfreder/ff_animhop Fix interact animation page jump FF

File last commit:

r16120:24b93a1d
r16225:5c3a5f18 merge
Show More
Using Interact.ipynb
169 lines | 4.1 KiB | text/plain | TextLexer
Brian E. Granger
Moving parallel->Parallel
r16057 {
"metadata": {
"name": "",
"signature": "sha256:d75ab1c53fa3389eeac78ecf8e89beb52871950f296aad25776699b6d6125037"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
Brian E. Granger
Refactoring interact examples.
r16092 "Interact"
Brian E. Granger
Moving parallel->Parallel
r16057 ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
Brian E. Granger
Refactoring interact examples.
r16092 "The `interact` function provides a high-level interface for creating user interface controls to use in exploring code and data interactively."
Brian E. Granger
Moving parallel->Parallel
r16057 ]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.html.widgets import interact, interactive, fixed\n",
"from IPython.html import widgets\n",
"from IPython.display import clear_output, display, HTML"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Basic interact"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a simple function that displays its arguments as an HTML table:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def show_args(**kwargs):\n",
" s = '<h3>Arguments:</h3><table>\\n'\n",
" for k,v in kwargs.items():\n",
" s += '<tr><td>{0}</td><td>{1}</td></tr>\\n'.format(k,v)\n",
" s += '</table>'\n",
" display(HTML(s))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"show_args(a=10, b='Hi There', c=True)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<h3>Arguments:</h3><table>\n",
"<tr><td>a</td><td>10</td></tr>\n",
"<tr><td>c</td><td>True</td></tr>\n",
"<tr><td>b</td><td>Hi There</td></tr>\n",
"</table>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x10efc0d50>"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's use this function to explore how `interact` works."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"i = interact(show_args,\n",
" Temp=(0,10),\n",
" Current=(0.,10.,0.01),\n",
" z=True,\n",
" Text=u'Type here!',\n",
" #Algorithm=['This','That','Other'],\n",
" a=widgets.FloatSliderWidget(min=-10.0, max=10.0, step=0.1, value=5.0)\n",
" )"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<h3>Arguments:</h3><table>\n",
"<tr><td>Current</td><td>4.99</td></tr>\n",
"<tr><td>Text</td><td>Type here!</td></tr>\n",
"<tr><td>z</td><td>True</td></tr>\n",
"<tr><td>a</td><td>5.0</td></tr>\n",
"<tr><td>Temp</td><td>5</td></tr>\n",
"</table>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x10efcca10>"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"i.widget"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<h3>Arguments:</h3><table>\n",
"<tr><td>Current</td><td>4.99</td></tr>\n",
"<tr><td>Text</td><td>Type here!</td></tr>\n",
"<tr><td>z</td><td>True</td></tr>\n",
"<tr><td>a</td><td>5.0</td></tr>\n",
"<tr><td>Temp</td><td>5</td></tr>\n",
"</table>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x10f027050>"
]
}
],
"prompt_number": 5
}
],
"metadata": {}
}
]
}