##// END OF EJS Templates
Backport PR #5488: Added missing require and jquery from cdn....
Backport PR #5488: Added missing require and jquery from cdn. For some reason (I suppose some changes at the css level) the font size inside the input cells was fixed at 14 px... making the fonts really small in the reveal slideshows. This is really annoying... As a plus, I have also added the missing calls for require and jquery (as the full html template does). I think these fixes belong to 2.0, but I also know we are on the edge... so I hope to get it inside :wink: Cheers.

File last commit:

r16120:24b93a1d
r16230:ba262623
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