ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 30 Apr 2012 17:01:48 -0500arrange sage interact input elementshttps://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/Is it possible to control the arrangement of the input elements like sliders or input boxes in sage interact? By default all elements are grouped below each other. Is it possible to change this arrangement in some way? For example is it possible to have 3 or 4 input boxes and sliders side by side in one row?Mon, 30 Apr 2012 05:59:20 -0500https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/Answer by Alex Kramer for <p>Is it possible to control the arrangement of the input elements like sliders or input boxes in sage interact? By default all elements are grouped below each other. Is it possible to change this arrangement in some way? For example is it possible to have 3 or 4 input boxes and sliders side by side in one row?</p>
https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?answer=13513#post-id-13513You should be able to accomplish this with the layout parameter to @interact. Here's one sample from the interact documentation:
@interact(layout={'top': [['a', 'b']], 'left': [['c']], 'bottom': [['d']]})
def _(a=x^2, b=(0..20), c=100, d=x+1): print a+b+c+d
Nested lists allow specification of both distinct rows of interact controls and distinct elements within each row, which is what I think you're asking about.Mon, 30 Apr 2012 11:37:03 -0500https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?answer=13513#post-id-13513Comment by kcrisman for <p>You should be able to accomplish this with the layout parameter to @interact. Here's one sample from the interact documentation:</p>
<pre><code>@interact(layout={'top': [['a', 'b']], 'left': [['c']], 'bottom': [['d']]})
def _(a=x^2, b=(0..20), c=100, d=x+1): print a+b+c+d
</code></pre>
<p>Nested lists allow specification of both distinct rows of interact controls and distinct elements within each row, which is what I think you're asking about.</p>
https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?comment=19846#post-id-19846Aack! That is what I was actually looking for, and got confused while looking around.Mon, 30 Apr 2012 17:01:48 -0500https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?comment=19846#post-id-19846Answer by kcrisman for <p>Is it possible to control the arrangement of the input elements like sliders or input boxes in sage interact? By default all elements are grouped below each other. Is it possible to change this arrangement in some way? For example is it possible to have 3 or 4 input boxes and sliders side by side in one row?</p>
https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?answer=13512#post-id-13512It sounds like you are looking for `input_grid`. Does [this documentation](http://www.sagemath.org/doc/reference/sagenb/notebook/interact.html#sagenb.notebook.interact.input_grid) help? Here is the example from there:
@interact
def _(m = input_grid(2,2, default = [[1,7],[3,4]],
label='M=', to_value=matrix),
v = input_grid(2,1, default=[1,2],
label='v=', to_value=matrix)):
try:
x = m\v
html('$$%s %s = %s$$'%(latex(m), latex(x), latex(v)))
except:
html('There is no solution to $$%s x=%s$$'%(latex(m), latex(v)))Mon, 30 Apr 2012 06:44:26 -0500https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?answer=13512#post-id-13512Comment by sagefan for <p>It sounds like you are looking for <code>input_grid</code>. Does <a href="http://www.sagemath.org/doc/reference/sagenb/notebook/interact.html#sagenb.notebook.interact.input_grid">this documentation</a> help? Here is the example from there:</p>
<pre><code>@interact
def _(m = input_grid(2,2, default = [[1,7],[3,4]],
label='M=', to_value=matrix),
v = input_grid(2,1, default=[1,2],
label='v=', to_value=matrix)):
try:
x = m\v
html('$$%s %s = %s$$'%(latex(m), latex(x), latex(v)))
except:
html('There is no solution to $$%s x=%s$$'%(latex(m), latex(v)))
</code></pre>
https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?comment=19848#post-id-19848Thanks, but can I combine this with sliders for example, i.e. in one row an input box, then two sliders, then two inputboxes...Mon, 30 Apr 2012 06:53:21 -0500https://ask.sagemath.org/question/8939/arrange-sage-interact-input-elements/?comment=19848#post-id-19848