From: Nasser M. Abbasi on 5 Dec 2009 05:35 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
From: David Park on 6 Dec 2009 01:33 Nasser, That is why I usually prefer custom presentations to Mathematica's various set-piece constructions, which I consider rather baroque. So I might do your construction the following way. It might look like more work because I have to specify precisely where everything is going and how it looks. But on the other hand I have more control and know precisely what I am doing. DynamicModule[ {left = 0, right = 0}, Panel[ Row[ {Column[{ Style["Side", 12], Style["left ", Red, 14]}], Manipulator[Dynamic[left], {0, 10}], Spacer[7], Text["test"], Spacer[7], Column[{ Style["Side", 12], Style["right ", Red, 14]}], Manipulator[Dynamic[right], {0, 10}] }], Style["Nasser's Custom Dynamic", 16], BaseStyle -> {FontSize -> 16}, ImageSize -> 550] ] David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Nasser M. Abbasi [mailto:nma(a)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
|
Pages: 1 Prev: Foldlist with more than one list as argument Next: How to combine Dynamic graphics in Show? |