Skip to content

Instantly share code, notes, and snippets.

@minrk
Created August 2, 2017 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/486c99a658b4b7b2aac96cfcf8fae37d to your computer and use it in GitHub Desktop.
Save minrk/486c99a658b4b7b2aac96cfcf8fae37d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "from IPython.display import display\nimport ipywidgets as W\nfrom traitlets import link",
"execution_count": 6,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "def coreCalculationFunction(myOptions):\n return myOptions\n\ndef optionsRelatedFunction():\n myOptions=['a', 'b', 'c']\n label = W.HTML(value=\"Hello World\")\n the_interact = W.interactive(coreCalculationFunction,\n myOptions=myOptions)\n dropdown = the_interact.children[0]\n \n # link ensures that when dropdown.value changes,\n # label.value gets the same value, and vice versa.\n # dlink is a unidirectional alternative.\n link((dropdown, 'value'),\n (label, 'value'),\n )\n display(label, the_interact)\n",
"execution_count": 21,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "optionsRelatedFunction()",
"execution_count": 20,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1400ebc3eb964d2e95cafb0a96eda5e3"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a52967f2ce1b41ada4999fd4d6266654"
}
},
"metadata": {}
}
]
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.0",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment