Tangling up interact

IPython's interact can do some things that are awkward with straight widgets, such as generating plots. It will magically make built-in widgets from some simple settings objects.


In [11]:
from IPython.html.widgets import interact
from math import (sin, cos, tan)
from ipytangle import tangle

If you have defined an interact function, you can pull out all of the variables and put them in a tangle.

Because you can only have one tangle per page right now, see [Interacting with a tangle](./Interacting with a tangle.ipynb).

In [12]:
@interact
def interactor(fn=dict(sin=sin, cos=cos, tan=tan), x=(0, 360)):
    print(fn(x))


-0.7265148944842826

The fn_label function

The fn_label of x is... some number.


In [13]:
trig_talk = tangle(interactor)
trig_talk


-0.4629845264892503