Another beginners question, I’m afraid.
I’m working on a demo with lots of controls, and I manage to distribute them Left, Right, Top & Bottom with ControlPlacement. But the Top & Bottom controls stay left-aligned and I would like to center them under the drawing.
Thanks for helping.
Is this the sort of behavior you are looking for:
Manipulate[{x, a, b}, {x, 0, 1},
Item[Control[{a, {0, 1}}], Alignment -> Center], {b, 0, 1}]
Not entirely a beginner question! ![]()
After edit (I added that control b has a caption).
Here is what I mean:
If you run this example:
Manipulate[Graphics[Circle[{a, b}, c]],
{a, 1, 10},
“Caption of b”,
{b, 1, 10}, {c, 1, 10},
ControlPlacement → {Left, Top, Top, Right}]
a & c will be indeed left & right, and “caption of b” & b on top, but to the left, instead of over the center of the circle..
David, I can’t get your suggestion to work.
The secret trick to obtain complete control of locations of controls is to use Manipulate[None,....] and then simply use Grid to layout everything. The dynamic content itself, can now be placed anywhere, and the controls in any location in the main display area. I like to use this method since now the controls can be placed near the dynamics it is supposed to manipulate. I found this method sometime ago by accident when I was trying to figure how solve similar problem you are having. With this method, any possible layout can be made very easily. Forget about ControlPlacement, and use the powerful Grid :). ps. Also Item can be very handy here.
Manipulate[None,
Grid[{{Grid[{{Control[{a, 1, 10}]},{"Caption of b"},{Control[{b, 1, 10}]}}],
Grid[{{Control[{c, 1, 10}]},{Dynamic@Plot[Sin[a x] + b c, {x, -2 Pi, 2 Pi}, ImagePadding -> 10,
AxesOrigin -> {0, 0}, Frame -> True]}}]}}, TrackedSymbols :> {a, b, c}]
Here is a demo that uses the above method DynamicAnalysisOfASecondOrderSystemWithHarmonicLoading
Looks great! Many thanks!!
The next step is to simply abandon Manipulate altogether and build your interactive with DynamicModule. Ultimately that is what I always end up doing if I start by creating a Manipulate. Typically though I almost always start with is, in fact, a DynamicModule: it gives you complete detailed control of your design.
Many thanks. I read about DynamicModule but it seemed daunting, but now I feel encouraged to get into it.
I found a primitive solution to my problem for the faint of heart: simply pad the b controls with spaces!
I would post the code, but the editor here takes the spaces right back out. Is there a way around that?
Also, how does one post a manipulate output like Nasser did? Or should I start a new question?
