In [1]:
from IPython.display import display, Image, HTML, clear_output
In [2]:
from IPython.html import widgets
In [3]:
dir(widgets)
Out[3]:
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]:
In [13]:
w.close()
In [14]:
m = widgets.interact(circle, r=(0,500,5))
m
Out[14]:
In [15]:
for r in range (0,500,5):
m.widget._children[0].value = r
time.sleep(0.1)