2
$\begingroup$

I want to have the numbers that a SetterBar displays for the user to select to appear as percentages. For example, the following code should have percentages not only in the output but also in the buttons for the setter bar:

Manipulate[
 Style["Percentage is " <> ToString@PercentForm@x, 
  FontFamily -> "Georgia"],
 {{x, .02, "Percentage:"}, Range[.01, .05, .01], 
  ControlType -> SetterBar, Background -> GrayLevel[.8], 
  Appearance -> "Row"}]

In other words, the white selected button and the gray unselected buttons should all be in the form of 1%, 2%, 3%, etc.

enter image description here

$\endgroup$
0

1 Answer 1

7
$\begingroup$

The docs list the control form {u,{u1->lbl1,u2->lbl2,...}} for the setter bar, so just use Rule[#, PercentForm[#]] & /@ Range[.01, .05, .01] instead of Range[.01, .05, .01].

$\endgroup$
1
  • $\begingroup$ Many thanks. I had tried {#->PercentForm@#}&/@... but it would not work, I should have tried Rule[ ]...; it turns out (#->PercentForm#)&/@... also works. $\endgroup$
    – Nicholas G
    Apr 8, 2022 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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