declarativewidgets
declarativewidgets copied to clipboard
Create a kernel function to produce a template to help invoke a function
This function is inspired by ipywidgets' interact()
function, but should create a declarativewidget template using urth-core-bind
on a specified channel.
def toTemplate( function, result='result', channel='default', auto=True )
- function - reference to function to expose as a declarative form
- result - name of binding variable to use for the result of the function. Used in other declarative templates
- channel - channel name to use
- auto - will determine to put a button to invoke of have the function auto invoke
The result of running toTemplate
(or any better name) would be something like this
def aFunction(a,b,c):
return "foo"
toTemplate(aFunction, result="x", channel="awesome")
<template is="urth-core-bind" channel="awesome">
<paper-input label="a" value="{{a}}"></paper-input>
<paper-input label="b" value="{{b}}"></paper-input>
<paper-input label="c" value="{{c}}"></paper-input>
<urth-core-function arg-a="{{a}}" arg-b="{{b}}" arg-c="{{c}}" auto result="{{x}}"></urth-core-function>
</template>
Would be nice if the function also had a mode that just prints the template as text and can then be copy/paste and modified into a real template in a %%html
cell.
/cc @deedubbu @parente
The main concern would be to also place the <link rel='import'>
tags. Maybe not a huge concern because if the element is already loaded, the link
should be a noop.