MathGroup Archive 2009

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

Search the Archive

Re: Custom label for a slider in Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96350] Re: Custom label for a slider in Manipulate
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Thu, 12 Feb 2009 06:35:13 -0500 (EST)
  • References: <gmu90d$grj$1@smc.vnet.net>

Hi,

> I have a simple Manipulate,
> 
> Manipulate[
>  Plot[Sqrt[2]/(RTT*Sqrt[p]), {p, .001, .1},
>   PlotRange -> {{0, .1}, {0, 150}}],
>  {{RTT, .1, "round trip time"}, .03, .25, Appearance -> "Labeled"}
>  ]
> 
> But I want the slider that controls the RTT variable to have a
> prettier appearance. I would like it to display the value to the right
> of the control, but instead of a plain number I want it to show
>   ToString[Round[1000 RTT]] <> "ms"
> 
> How can I achieve this?

I'm sure you can talk Manipulate into doing what you want, but it is one
of the cases where I think creating the interface from scratch using
Dynamic and DynamicModule is more straight forward:

Deploy[Panel[DynamicModule[{RTT = 0.1},
   Column[{
     Grid[{{
        "round trip time",
        Manipulator[Dynamic[RTT], {0.03, 0.25}],
        InputField[
         Dynamic[Round[1000 RTT]],
         Appearance -> None, ImageSize -> 20, Enabled -> False
         ],
        "ms"
        }}],
     Panel[
      Dynamic[
       Plot[Sqrt[2]/(RTT*Sqrt[p]), {p, .001, .1},
        PlotRange -> {{0, .1}, {0, 150}}]
       ], Background -> White]
     }]
   ]]]

if you want the value to work as a Controle, that is only slightly more
complicated:

Deploy[Panel[DynamicModule[{RTT = 0.1},
   Column[{
     Grid[{{
        "round trip time",
        Manipulator[Dynamic[RTT], {0.03, 0.25}],
        InputField[
         Dynamic[Round[1000 RTT], (RTT = #/1000) &],
         Appearance -> None, ImageSize -> 20
         ],
        "ms"
        }}],
     Panel[
      Dynamic[
       Plot[Sqrt[2]/(RTT*Sqrt[p]), {p, .001, .1},
        PlotRange -> {{0, .1}, {0, 150}}]
       ], Background -> White]
     }]
   ]]]

hth,

albert


  • Prev by Date: Re: linear regression with errors in both variables
  • Next by Date: Re: Dynamic changing of variables
  • Previous by thread: Custom label for a slider in Manipulate
  • Next by thread: Re: Custom label for a slider in Manipulate