Finding how to do things by trial and error
- To: mathgroup at smc.vnet.net
- Subject: [mg105497] Finding how to do things by trial and error
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Sat, 5 Dec 2009 05:33:41 -0500 (EST)
- Reply-to: "Nasser M. Abbasi" <nma at 12000.org>
This is just some rambling on my part. Nothing serious:
Mathematica can sometimes require lots of trial and error to find how to do
something.
This is a small example, which took me 15 minutes to find how to do.
I wanted to make a Manipulate with one control to the left and one to the
right of the display and I wanted to label these controls using Style[].
Ofcourse I wanted to Labels to be on the same side as the controls.
I can use ControlPlacement to put one Control on the right, and one on the
left. But what about the labels? ControlPlacement does not go with Style[].
Yet, if I give one general "global" ControlPlacement, then Styles will
follows the ControlPlacement as expected, as follows:
-------------------------------------------
Manipulate[Text["test"],
Style["left", 10],
Control[{left, 1, 10}],
Style["right", 10],
Control[{right, 1, 10}],
ControlPlacement -> {Left, Left, Right, Right}
]
----------------------------
But I really like to have the ControlPlacement inside each Control[] so it
is easier for me to see where each Control is located.
But If I write
--------------------------------------
Manipulate[Text["test"],
Style["left", 10],
Control[{left, 1, 10,ControlPlacement -> Left}],
Style["right", 10],
Control[{right, 1, 10,ControlPlacement -> Right}]
]
-------------------------------------
The above will not work, as now the Styles have default placement which is
Left and so the Styles no longer in the correct locations.
So I needed something what will take ControlPlacement but also allow Style
to be in it. After trying Row[] and Column[] and Grid[] and large coffee and
none of worked as these do not take ControlPlacement, then I remembered that
amazing one thing called Item[] which I discovered the other day, and it did
the trick:
------------------------------
Manipulate[Text["test"],
Item[Style["left", 10], ControlPlacement -> Left],
Control[{left, 1, 10, ControlPlacement -> Left}],
Item[Style["right", 10],ControlPlacement -> Right],
Control[{right, 1, 10, ControlPlacement -> Right}]
]
------------------------------------------
My point in all of this, is that the first example I showed above,
ControlPlacement worked on Styles[] as is when ControlPlacement was the
general "global" one. And one did not need to use Item[] then.
It seems to me that sometimes finding little things like this is what makes
learning Mathematica a continuous ongoing activity.
--Nasser