建立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}]
有没有办法让面板在彼此的顶部与相应的SetterBar对齐?
答案 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}]
这在技术上将控件移动到操纵体内,并防止实际控件显示在正常位置。
答案 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]}
}
]
]
]
答案 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]