In [1]:
from IPython.display import display, Image, HTML, clear_output

In [2]:
from IPython.html import widgets

In [3]:
dir(widgets)


Out[3]:
['AccordionWidget',
 'BoundedFloatTextWidget',
 'BoundedIntTextWidget',
 'ButtonWidget',
 'CallbackDispatcher',
 'CheckboxWidget',
 'ContainerWidget',
 'DOMWidget',
 'DropdownWidget',
 'FloatProgressWidget',
 'FloatSliderWidget',
 'FloatTextWidget',
 'HTMLWidget',
 'ImageWidget',
 'IntProgressWidget',
 'IntSliderWidget',
 'IntTextWidget',
 'LatexWidget',
 'PopupWidget',
 'RadioButtonsWidget',
 'SelectWidget',
 'TabWidget',
 'TextWidget',
 'TextareaWidget',
 'ToggleButtonWidget',
 'ToggleButtonsWidget',
 'Widget',
 '__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 'fixed',
 'interact',
 'interaction',
 'interactive',
 'widget',
 'widget_bool',
 'widget_button',
 'widget_container',
 'widget_float',
 'widget_image',
 'widget_int',
 'widget_selection',
 'widget_selectioncontainer',
 'widget_string']

In [4]:
%%html
<svg height="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>



In [5]:
def circle(r=40):
    
    cx = int(1.25*r)
    cy = cx
    height = 2*cx
    
    html = """<svg height="{height}">
  <circle cx="{cx}" cy="{cy}" r="{r}" stroke="black" stroke-width="3" fill="red" />
</svg>
""".format(height=height, cx=cx, cy=cy, r=r)
    display(HTML(html))

In [6]:
circle()



In [7]:
widgets.interact(circle, r=(0,500,5))



In [8]:
w = widgets.FloatSliderWidget()
w.min = 0
w.max  = 200
w.value = 30

In [9]:
w

In [10]:
w.value = 50

In [11]:
import time

for m in range(0,200,2):
    w.value = m
    time.sleep(0.1)

In [12]:
w.keys


Out[12]:
['_view_name',
 'orientation',
 'msg_throttle',
 'min',
 'max',
 '_css',
 'value',
 'readout',
 'disabled',
 'visible',
 'step',
 'description']

In [13]:
w.close()

In [14]:
m = widgets.interact(circle, r=(0,500,5))
m


Out[14]:
<function __main__.circle>

In [15]:
for r in range (0,500,5):
    m.widget._children[0].value = r
    time.sleep(0.1)