##// END OF EJS Templates
never use `for (var i in array)`...
never use `for (var i in array)` because javascript is terrible

File last commit:

r16120:24b93a1d
r16226:574fdef3
Show More
Using Interact.ipynb
169 lines | 4.1 KiB | text/plain | TextLexer

Interact

The interact function provides a high-level interface for creating user interface controls to use in exploring code and data interactively.

In [1]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import clear_output, display, HTML

Basic interact

Here is a simple function that displays its arguments as an HTML table:

In [2]:
def show_args(**kwargs):
    s = '<h3>Arguments:</h3><table>\n'
    for k,v in kwargs.items():
        s += '<tr><td>{0}</td><td>{1}</td></tr>\n'.format(k,v)
    s += '</table>'
    display(HTML(s))
In [3]:
show_args(a=10, b='Hi There', c=True)

Arguments:

a10
cTrue
bHi There

Let's use this function to explore how interact works.

In [4]:
i = interact(show_args,
         Temp=(0,10),
         Current=(0.,10.,0.01),
         z=True,
         Text=u'Type here!',
         #Algorithm=['This','That','Other'],
         a=widgets.FloatSliderWidget(min=-10.0, max=10.0, step=0.1, value=5.0)
         )

Arguments:

Current4.99
TextType here!
zTrue
a5.0
Temp5
In [5]:
i.widget

Arguments:

Current4.99
TextType here!
zTrue
a5.0
Temp5