500
500

Reputation: 6629

Adjust Panel Location in a Manipulate object in mathematica

Building up on Sjoerd solution to add alignment to a manipulate object :

Consider the following :

Manipulate[
 Panel[Style[Row1, Bold, 20],
   ImageSize -> 150, Alignment -> Center]
 Panel[Style[Row2, Bold, 20],
   ImageSize -> 150, Alignment -> Center],
{{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left},
{{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}]

enter image description here

Is there a way to have the panel on top of each other aligned with the corresponding SetterBar ?

Upvotes: 3

Views: 614

Answers (3)

Sjoerd C. de Vries
Sjoerd C. de Vries

Reputation: 16232

DynamicModule[{Row1 = 1, Row2 = 2},
 Manipulate[
  Grid[
   {
    {
      Control[{Row1, {1, 2, 3, 4, 5}}],
      Panel[Style[Row1, Bold, 20], ImageSize -> 150,  Alignment -> Center]
    }, 
    {
      Control[{Row2, {1, 2, 3, 4, 5}}], 
      Panel[Style[Row2, Bold, 20], ImageSize -> 150,  Alignment -> Center]}
    }
   ]
  ]
 ]

enter image description here

Upvotes: 3

Dr. belisarius
Dr. belisarius

Reputation: 61046

You could also do:

Manipulate[
 Column[
  {Panel[Style[Row1, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center] , 
   Panel[Style[Row2, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center]}],
 Column[
 {
 Control@{{Row1,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar},
 Control@{{Row2,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar}
   }],
 ControlPlacement -> Left]  

enter image description here

Upvotes: 1

Brett Champion
Brett Champion

Reputation: 8577

Would something like this work?

Manipulate[
 Grid[{{SetterBar[Dynamic[Row1], {1, 2, 3, 4, 5}], 
    Panel[Style[Row1, Bold, 20], ImageSize -> 150, 
     Alignment -> Center] }, {SetterBar[
     Dynamic[Row2], {1, 2, 3, 4, 5}], 
    Panel[Style[Row2, Bold, 20], ImageSize -> 150, 
     Alignment -> Center]}}], {{Row1, {1}}, 
  ControlType -> None}, {{Row2, {2}}, ControlType -> None}]

manipulate screenshot

This technically moves the controls into the body of the manipulate, and prevents the actual controls from showing up where they normally would.

Upvotes: 3

Related Questions