在mathematica中的Manipulate对象中调整Panel Location

时间:2011-06-24 17:11:00

标签: wolfram-mathematica panel setter

建立Sjoerd solution to add alignment to a manipulate object

请考虑以下事项:

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

有没有办法让面板在彼此的顶部与相应的SetterBar对齐?

3 个答案:

答案 0 :(得分:3)

这样的事情会起作用吗?

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

这在技术上将控件移动到操纵体内,并防止实际控件显示在正常位置。

答案 1 :(得分:3)

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

答案 2 :(得分:1)

你也可以这样做:

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