Skip to content

Instantly share code, notes, and snippets.

@lbustelo
Last active March 2, 2016 20:57
Show Gist options
  • Save lbustelo/18740343028cb34a8753 to your computer and use it in GitHub Desktop.
Save lbustelo/18740343028cb34a8753 to your computer and use it in GitHub Desktop.
Issue 245 jupyter_declarativewidgets
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%html\n",
"<link rel=\"import\" href=\"urth_components/paper-menu/paper-menu.html\" is='urth-core-import' package='PolymerElements/paper-menu'>\n",
"<link rel=\"import\" href=\"urth_components/paper-item/paper-item.html\" is='urth-core-import' package='PolymerElements/paper-item'>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def test(items:list):\n",
" return items"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Does not work when using `args-*` style\n",
"\n",
"This is basically the issue in https://github.com/jupyter-incubator/declarativewidgets/issues/245"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%html\n",
"<template is=\"dom-bind\">\n",
" <urth-core-function ref=\"test\" arg-items=\"{{selections}}\" result=\"{{theResult}}\" auto></urth-core-function>\n",
" \n",
" <paper-menu attr-for-selected=\"label\" multi selected-values=\"{{selections}}\">\n",
" <paper-item label=\"1\">Network 1</paper-item>\n",
" <paper-item label=\"2\">Network 2</paper-item>\n",
" <paper-item label=\"3\">Network 3</paper-item>\n",
" </paper-menu>\n",
" \n",
" The function result <span>{{theResult}}</span><br/>\n",
" \n",
"</template>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Workaround using `args` property\n",
"\n",
"This part still have issues describe on https://github.com/jupyter-incubator/declarativewidgets/issues/247"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%html\n",
"<template is=\"dom-bind\">\n",
" <urth-core-function ref=\"test\" args=\"{{theArgs}}\" result=\"{{theResult}}\" auto></urth-core-function>\n",
" \n",
" <paper-menu attr-for-selected=\"label\" multi selected-values=\"{{theArgs.items}}\">\n",
" <paper-item label=\"1\">Network 1</paper-item>\n",
" <paper-item label=\"2\">Network 2</paper-item>\n",
" <paper-item label=\"3\">Network 3</paper-item>\n",
" </paper-menu>\n",
" \n",
" The function result <span>{{theResult}}</span><br/>\n",
" \n",
"</template>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Workaround using `urth-core-watch`\n",
"\n",
"This is too convoluted but works reliably"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%html\n",
"<template is=\"dom-bind\">\n",
" <urth-core-watch value=\"{{selections}}\">\n",
" <urth-core-function ref=\"test\" arg-items=\"[[selections]]\" result=\"{{theResult}}\"></urth-core-function>\n",
" </urth-core-watch>\n",
" <paper-menu attr-for-selected=\"label\" multi selected-values=\"{{selections}}\">\n",
" <paper-item label=\"1\">Network 1</paper-item>\n",
" <paper-item label=\"2\">Network 2</paper-item>\n",
" <paper-item label=\"3\">Network 3</paper-item>\n",
" </paper-menu>\n",
" \n",
" The function result <span>{{theResult}}</span><br/>\n",
" \n",
"</template>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.4.4"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment