4
$\begingroup$

I want to make a vertical RadioButtonBar in Manipulate. So far I only have a workaround that looks like this:

Manipulate[
  Which[
  sel == 0,
  Text["one"],

  sel == 1,
  Text["two"],

  sel == 2,
  Text["three"]
  ],
  Control[{{sel, 0, ""}, {0 -> "one"}, ControlType -> RadioButton}],
  Control[{{sel, 1, ""}, {1 -> "two"}, ControlType -> RadioButton}],
  Control[{{sel, 2, ""}, {2 -> "three"}, 
  ControlType -> RadioButton}],

  ControlPlacement -> Left
  ]

Is there any way not to have a line for each of the radiobuttons? Thanks!

$\endgroup$
1
  • $\begingroup$ Take a look at RadioButtonBar if it helps. $\endgroup$ – VLC Nov 21 '12 at 10:21
6
$\begingroup$
Manipulate[
 Switch[sel,
  0, Text["one"],
  1, Text["two"],
  2, Text["three"]], {{sel, 0, ""}, {0 -> "one", 1 -> "two", 
   2 -> "three"}, ControlType -> RadioButtonBar, 
  Appearance -> "Vertical"}, ControlPlacement -> Left]

enter image description here

$\endgroup$
1
  • $\begingroup$ Great! Thanks a lot. - I did check for the 'Appearance -> "Vertical"' option, but obviously must have done something wrong. I'm glad it's working now. $\endgroup$ – Mockup Dungeon Nov 21 '12 at 12:11
3
$\begingroup$

You can try the Dynamic function as follows:

DynamicModule[{sel}, 
 Panel[Row[{RadioButtonBar[
     Dynamic[sel], {1 -> "One", 2 -> "Two", 3 -> "Three"}, 
     Appearance -> "Vertical"], 
    Panel[Dynamic[
      Which[sel == 1, Text["one"], sel == 2, Text["two"], sel == 3, 
       Text["three"]]], ImageSize -> {50, 50}]}]]]

This avoids to to have a line for each of the radiobuttons.

$\endgroup$
1
  • $\begingroup$ I know DynamicModule is much more flexible, but unfortunately I did not have time yet to familiarise myself with it. - But thanks a lot for the suggestion! I'll keep the code and come back to it later. $\endgroup$ – Mockup Dungeon Nov 21 '12 at 12:13

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.