ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 18 Nov 2011 05:22:58 +0100couple sliders on checkbox clickhttps://ask.sagemath.org/question/8489/couple-sliders-on-checkbox-click/Consider the following example:
@interact
def _(a=slider(0,10,1,default=2),b=slider(0,10,1,default=5),equal=checkbox(False)):
a=2
Is it possible, that after clicking on the checkbox, the position of the second slider becomes equal to that of the first slider and that, as long as the checkbox is checked, both sliders are coupled, i.e. if you change one, the other one changes by the same value.
Fri, 18 Nov 2011 05:10:59 +0100https://ask.sagemath.org/question/8489/couple-sliders-on-checkbox-click/Answer by Jason Grout for <p>Consider the following example:</p>
<pre><code>@interact
def _(a=slider(0,10,1,default=2),b=slider(0,10,1,default=5),equal=checkbox(False)):
a=2
</code></pre>
<p>Is it possible, that after clicking on the checkbox, the position of the second slider becomes equal to that of the first slider and that, as long as the checkbox is checked, both sliders are coupled, i.e. if you change one, the other one changes by the same value.</p>
https://ask.sagemath.org/question/8489/couple-sliders-on-checkbox-click/?answer=12917#post-id-12917There's not an easy way to lock the sliders, though you could easily ignore one of the sliders if the checkbox was checked.
@interact
def _(a=slider(0,10,1,default=2),b=slider(0,10,1,default=5),equal=checkbox(False)):
if equal:
b=a
print a, b
Fri, 18 Nov 2011 05:22:58 +0100https://ask.sagemath.org/question/8489/couple-sliders-on-checkbox-click/?answer=12917#post-id-12917