Hi,

I was playing around with using @interact in the Sage library and it
almost works... and with one small hack it seems to work fine.   You
just have to know how to use it.

As an example, put the following (see below) in a file such as
SAGE_ROOT/devel/sage/sage/a.py, then do "sage -br" and finally do

   import sage.a

   sage.a.test1()

or

   sage.a.test2()

In the notebook, you should get interactive functions.    The only
subtlety is the line

    html("</pre>")

which turns off pre mode in HTML, which is needed since otherwise the
controls are spaced out too much.

William


-------------

from sagenb.notebook.interact import interact, slider, range_slider
from sage.misc.html import html

def test1():
    html("</pre>")
    @interact
    def f(n=tuple(range(10)), m=tuple(range(10))):
        print n+m

def test2():
    html('</pre>')
    @interact
    def mandel_plot(expo = slider(-10,10,0.1,2), \
                          formula = list(['mandel','ff']),\
                          iterations=slider(1,100,1,30), \
                          zoom_x = range_slider(-2,2,0.01,(-2,1)), \
                    zoom_y = range_slider(-2,2,0.01,(-1.5,1.5))):
        print expo


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to