3
$\begingroup$

For example

Manipulate[i, {i, 1, 100, 1}, ControlType -> SetterBar]

will have a long setterbar, I want it wrap to several lines. The Appearance->"Row" option of SetterBar seems does the job.

But how to set Appearance of SetterBar in Manipulate?

$\endgroup$
5
  • 2
    $\begingroup$ The ControlType and Appearance go inside the control definition: Manipulate[i, {i, 1, 100, 1, ControlType -> SetterBar, Appearance -> "Row"}] $\endgroup$
    – Bob Hanlon
    Aug 18, 2016 at 16:59
  • 1
    $\begingroup$ You could also use Manipulate[i, {i, 1, 100, 1, Appearance -> "Row"}, ControlType -> SetterBar] $\endgroup$
    – Bob Hanlon
    Aug 18, 2016 at 17:12
  • 1
    $\begingroup$ Or Manipulate[i, {i, 1, 100, 1, SetterBar, Appearance -> "Row"}]. $\endgroup$
    – Karsten7
    Aug 18, 2016 at 21:01
  • 2
    $\begingroup$ As an alternative: Manipulate[i, {i, 1, 100, 1, SetterBar, Appearance -> "Horizontal" -> {4, Automatic}}] $\endgroup$
    – Karsten7
    Aug 19, 2016 at 1:09
  • $\begingroup$ Thank you so much @Karsten7. Now the buttons are aligned. However, they become truly one bar without delimit lines for each button! I think I can ask no more, life is not perfect : ) $\endgroup$
    – matheorem
    Aug 19, 2016 at 1:43

2 Answers 2

7
$\begingroup$

The simplest way is

Manipulate[i, {i, 1, 100, 1, SetterBar, Appearance -> "Row"}]

setterbar

Update

If you don't like the look of the "Row" layout and actually want a grid-like layout, you can write

Manipulate[i,
  {i, 1, 100, 1, SetterBar, Appearance -> "Horizontal" -> {Automatic, 20}}]

setterbar

However, note how this layout affects the look of the buttons and the label placement.

$\endgroup$
5
  • $\begingroup$ Thank you m_goldberg. There is one more issue. Why the first row and second row are not aligned? Look at "1" and "26", that is ugly. $\endgroup$
    – matheorem
    Aug 19, 2016 at 0:36
  • $\begingroup$ @matheorem. It's deliberate. It's the way Mathematica likes to show that what might be mistaken for a grid of elements is really a long row that has been broken up. $\endgroup$
    – m_goldberg
    Aug 19, 2016 at 7:13
  • $\begingroup$ Hey, m_goldberg. You must be using Mac system. right? On windows, it looks like this pasteboard.co/aqSU7DbTl.png , no delimit !! Ugly than yours. This is unfair : ( and this is what I communicated with Karsten 7. to seek a better looking. $\endgroup$
    – matheorem
    Aug 19, 2016 at 7:30
  • $\begingroup$ @matheorem. Yes, I run Mathematica on OS X. $\endgroup$
    – m_goldberg
    Aug 19, 2016 at 7:33
  • $\begingroup$ Mac is more beautiful on this. Thanks for showing this : ) $\endgroup$
    – matheorem
    Aug 19, 2016 at 7:35
4
$\begingroup$
Manipulate[i, 
 {i, 1, 100, 1, Style[Row[Setter[Dynamic[i], #] & /@ Range @@ #2], LineIndent -> 0] &}]

perfectOut

$\endgroup$
4
  • $\begingroup$ Thank you so much for introducing Setter, Karsten 7. I figure out a better looking button array Manipulate[i, {i, 1, 100, 1, Grid[Partition[(Setter[Dynamic[i], #] & /@ Range[#2[[2]]]), 20], Spacings -> {0.5, 0.5}] &}] : ) $\endgroup$
    – matheorem
    Aug 19, 2016 at 7:22
  • $\begingroup$ One more issue. I am unable to figure out what does #2 really mean. For example, How to do with this Manipulate[i,{i,List}]? I tried #1 and others, all failed $\endgroup$
    – matheorem
    Aug 19, 2016 at 7:24
  • $\begingroup$ @matheorem #2 grabs the range of i. For this example it's {1,100,1}. I edited the answer, because Range @@ #2 might be more intuitive than Range[#2[[2]]]. Try Manipulate[i, {{i, 1}, {1, 2, 3, 5}, Row[Setter[Dynamic[i], #] & /@ Flatten[#2]] &}] $\endgroup$
    – Karsten7
    Aug 19, 2016 at 12:47
  • $\begingroup$ I see. Thank you so much. $\endgroup$
    – matheorem
    Aug 19, 2016 at 12:54

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.