MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding how to do things by trial and error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105524] Re: [mg105497] Finding how to do things by trial and error
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 6 Dec 2009 01:32:40 -0500 (EST)
  • References: <29247351.1260011115072.JavaMail.root@n11>

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 at comcast.net
http://home.comcast.net/~djmpark/  

 

From: Nasser M. Abbasi [mailto: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 





  • Prev by Date: Re: Special Input Characters' Reference Table
  • Next by Date: how to perform ninefold integration
  • Previous by thread: Finding how to do things by trial and error
  • Next by thread: new general triangle form : w=2 is Pascal