5
$\begingroup$

I have a question about the SetterBar function. Is there any way to extract the selected value to use it further?

myValue = SetterBar[2, Range[5]]
myValue * 2
$\endgroup$
1
  • 1
    $\begingroup$ does 2 Setting[myValue] give what you need? $\endgroup$ – kglr Mar 7 at 17:48
7
$\begingroup$

Setting

You can use Setting: enter image description here

myValue = SetterBar[2, Range[5]]

enter image description here

2 Setting[myValue]
4

Dynamic

Alternatively, you can to use Dynamic:

enter image description here

Generalized input

Finally, you can use Setting and Evaluate In Place the setter bar to make the setter bar an input expression:

Highlight SetterBar[2, Range[5]] in

Setting[2 SetterBar[2, Range[5]]]

and hit CTRLSHIFTEnter to get

enter image description here

Select a value in the setter bar and hit SHIFTEnter to get

enter image description here

enter image description here

See also: the tutorial Generalized Input

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.