Skip to content

Instantly share code, notes, and snippets.

@jdfreder
Created February 6, 2015 20:17
Show Gist options
  • Save jdfreder/b71ab81375a3d0f71f9c to your computer and use it in GitHub Desktop.
Save jdfreder/b71ab81375a3d0f71f9c to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from IPython.html.widgets import FloatText, FloatSlider, Button\n",
"from IPython.display import display\n",
"from IPython.utils.traitlets import link\n",
"\n",
"widgets = []\n",
"for x in list('abcdef'):\n",
" widgets.append(FloatText(description=x))\n",
"\n",
"a = FloatSlider()\n",
"b = FloatSlider()\n",
"link((a, 'value'), (b, 'value'))\n",
"\n",
"def go(sender):\n",
" from time import sleep\n",
" from random import random\n",
"\n",
" while True:\n",
" for w in widgets:\n",
" w.value = random()\n",
" sleep(0.01)\n",
"go_btn = Button(description=\"Go!\")\n",
"go_btn.on_click(go)\n",
"\n",
"display(*widgets)\n",
"display(a,b)\n",
"display(go_btn)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment