sagemath/sagecell — pull request #265 by ihanson (2012-03-06 17:58:53+00:00)
Title: Use default values for interact controls directly in initial interact execution

This fixes #248. There are also changes to the way the `raw` argument to the `InputBox` function works.

Note that this fix causes the behavior of `input_box` to duplicate (almost) the functionality of the notebook. This means that, while the code from gh-248 works as expected, if you change the generated text box to something like ``x + y + z``, it gives a possibly unexpected error. This is the same thing that happens in the notebook. The cause of this is that the `SR` type’s `__repr__` function does _not_ return a string that evaluates to the same object: `repr(SR("x+y")) == "x + y"`; this string is what goes in the text field by default, but updating the interact causes it to be evaluated as raw code.

This commit causes one difference in `input_box` from the original: if you pass a string as the default, with no `type` argument, it creates a “raw” input box whose default is the `repr` of the string, rather than the string itself. This is more intuitive than the original, which has would just load the contents of the string as the default, meaning that updating the interact would cause Sage to attempt to evaluate the contents as code.