1 | initial version |
I don't know of a way to do this with the current interact implementation in Sage. You can do it with the singlecell server (which just executes a single Sage command, but you can embed it in any webpage), and hopefully soon the new interact implementation in the singlecell server will make its way back into Sage.
2 | No.2 Revision |
I don't know of a way to do this with the current interact implementation in Sage. You can do it with the singlecell server (which just executes a single Sage command, but you can embed it in any webpage), and hopefully soon the new interact implementation in the singlecell server will make its way back into Sage.
Of course, if you just want to get input from the user in the notebook, you can just ask them to define the variables.
3 | No.3 Revision |
I don't know of a way to do this with the current interact implementation in Sage. You can do it with the singlecell server (which just executes a single Sage command, but you can embed it in any webpage), and hopefully soon the new interact implementation in the singlecell server will make its way back into Sage.
For example, paste this into sagemath.org:5467
@interact
def f(numbers=(1,10,1)):
@interact(controls=[('x%d'%i, (0,10)) for i in range(numbers)])
def s(multiplier=2, **kwargs):
print "sum of numbers times multipler is", sum(kwargs.values())*multiplier
Of course, if you just want to get input from the user in the notebook, you can just ask them to define the variables.
4 | No.4 Revision |
I don't know of a way to do this with the current interact implementation in Sage. You can do it with the singlecell server (which just executes a single Sage command, but you can embed it in any webpage), and hopefully soon the new interact implementation in the singlecell server will make its way back into Sage.
For example, paste see this into sagemath.org:5467example on aleph.sagemath.org:
@interact
def f(numbers=(1,10,1)):
@interact(controls=[('x%d'%i, (0,10)) for i in range(numbers)])
def s(multiplier=2, **kwargs):
expr = "%s*(%s)"%(multiplier, '+'.join(sorted(kwargs)))
print "sum of numbers times multipler is", sum(kwargs.values())*multiplier
"%s is %s"%(expr, sum(kwargs.values())*multiplier)
Of course, if you just want to get input from the user in the notebook, you can just ask them to define the variables.