Hi there, I've a problem with interact together with a request:
I'd like to write a function which return some interact, for example: def make_interact(i): def _(choice=["x%i"%u for u in range(i)]): print choice return interact(_) However, if I write that the various choices are setup vertically. As in [x0] choice [x1] [x2] I'd rather have them setup horizontally as choice [x0] [x1] [x2] which is the case when I write as usual: @interact def _(choice=["x%i"%u for u in range(3)]): print choice or def make_interact_correct(i): def _(choice=["x%i"%u for u in range(i)]): print choice return _ interact(make_interact_correct(3)) Note also that I get on the screen <function _ at 0x4d36a28> after the interact. Am I doing something wrong or stupid ? I've another question about interact. I use them to demonstrate some algorithms during my course. So using yield I have a button [Step] which allow me to execute the algorithm step by step as in a debugger. At each step I draw some figure so show the status of the algorithm. I'd like to have a button [Cont] such that the figure are shown in sequence but without waiting for me to click on my browser. Is this feature easily achievable ? For those who are interested, I'm teaching algorithm and in particular sorts and here is the code for the insert sort. Cheers, Florent def trace_algo(cmd): sort_gen = iter(cmd) def bla(trace=selector(["Step", "Cont"], buttons=True)): global dessin try: mess, dessin = sort_gen.next() except StopIteration: mess = "======== Fin =======" print mess dessin.show() return interact(bla) def plot_tab(tab): return sum(point(v, size=40) for v in enumerate(tab)) def vert(i, tab, color="red"): return line([(i, 0),(i, max(tab))], color=color) def horiz(i, tab, color="green"): return line([(0,i),(len(tab),i)], color=color) def insert_sort(T): def dessin(): return ("i=%i, j=%i, e=%i"%(i,j,e), plot_tab(T)+vert(j, tab)+horiz(e, tab)) yield "Start", plot_tab(T) for i in range(1,len(T)): e = T[i] j = i yield dessin() while j>0 and T[j-1] > e: T[j] = T[j-1] j -= 1 yield dessin() T[j] = e yield dessin() -- 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