sagemath/sagecell — pull request #413 by ihanson (2013-06-13 05:56:36+00:00)
Title: New functionality for interacts

This pull request contains changes that allows the user to access and manipulate the values of interact controls after the interact has been defined and displayed on the page. For example, if an interact is defined as follows in one cell:
```python
@interact
def f(x=(1, 10)):
print x
```
and the following code is subsequently executed in a linked cell:
```python
print f.x
f.x = 4.0
```
the second cell will print out the current value of the slider, and then the slider will move to the value 4.0 and the first cell will print out that new value.

There are also some changes behind the scenes in the implementation of the interact controls. Each control now keeps track of its own value, rather than having that value stored in a global dictionary. Subclasses of the `InteractControl` class now have a method called `constrain`, which will be called any time the value of that control is set. This method modifies the value so that it always falls within the space of values allowed by that control. For example, the constraint on the value of a continuous slider is to be within the bounds of that slider, and of type `float`. (Previously, when such a slider was positioned at an integer value, that value would be passed directly to the interact function as an `int`.) This is distinct from the `adapter` property of the control in that the adapter is run on the value, already constrained, immediately before the function is executed, but the adapted value is never stored as the value.

When dealing with controls such as the `InputGrid` which have multiple values, the accessor for that value will return a list-like object containing those values. They cannot be set as a group (e.g. `func.grid = [[1, 2, 3], [4, 5, 6]]`), but they can be set individually (`func.grid[1][2] = 7`).