I just spent some time thinking about how to specify layouts for 
interact controls.  Here's a possible syntax:

@interact(layout=[['a','b'],['c','d']])
def _(a=1,b=(2,3),c="hi",d=x+1):
     print a,b,c,d


This would lay out a table with a and b in the same row, then c and d in 
the same row.

More generally, we can use templates (jinja2?) and html:

@interact(layout="""
some template code, containing variables a, b, c, d, that are each set 
to the html representation of the control
""")
def _(a=1,b=(2,3),c="hi",d=x+1):
     print a,b,c,d


What do people think?  I think these changes would be fairly easy to 
implement, and would be backwards-compatible with what we have now.

Another option would be having the layout a parameter of the actual 
function:

@interact
def _(a=1,b=(2,3),c="hi",d=x+1, layout="""
some template code, containing variables a, b, c, d, that are each set 
to the html representation of the control
""")):
     print a,b,c,d

Or we could do things more like mathematica does, and let you just 
specify the layout when you specify the variables:

@interact
def _(row(('a',1),('b',(2,3))),row(['c',"hi"],['d',x+1])):
     print a,b,c,d

or something.  This sort of obscures the variables you are using, 
though, and makes it hard to change layouts; it greatly confuses the 
content and presentation.  It also makes it difficult to use the 
function outside of interacts, whereas separately specifying the layout 
as above makes it easy to use the function outside of the interact 
framework.

Thanks,

Jason


-- 
Jason Grout


--~--~---------~--~----~------------~-------~--~----~
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