Ask Your Question
1

couple sliders on checkbox click

asked 13 years ago

Xtux gravatar image

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 13 years ago

Jason Grout gravatar image

There'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
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 371 times

Last updated: Nov 18 '11