declarativewidgets icon indicating copy to clipboard operation
declarativewidgets copied to clipboard

Create a kernel function to produce a template to help invoke a function

Open lbustelo opened this issue 8 years ago • 2 comments

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.

lbustelo avatar May 05 '16 20:05 lbustelo

/cc @deedubbu @parente

lbustelo avatar May 05 '16 20:05 lbustelo

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.

lbustelo avatar May 05 '16 20:05 lbustelo