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: [mg96358] Re: [mg96328] Custom label for a slider in Manipulate
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 12 Feb 2009 06:36:40 -0500 (EST)
  • References: <24638898.1234348258845.JavaMail.root@m02>

Damon,

Throw Manipulate into the ashcan and make your own dynamic display.

DynamicModule[
 {RTT = .1},
 Panel[
  Column[
   {Row[
     {"Round Trip Time: ",
      Slider[Dynamic[RTT], {0.03, 0.25}, Appearance -> Small],
      Spacer[10],
      Dynamic@
       Style[PaddedForm[Round[1000 RTT], 3], FontFamily -> "Courier"],
       Spacer[2], "ms"
      }](* Row *),
    Dynamic@
     Plot[Sqrt[2]/(RTT*Sqrt[p]), {p, .001, .1}, 
      PlotRange -> {{0, .1}, {0, 150}},
      ImageSize -> 400]}](* Column *),
  Style["Custom Dynamic Display", 16],
  BaseStyle -> {FontSize -> 14}
  ](* Panel *)
 ]

You could also have used a Manipulator rather than a Slider. I didn't want
the value on the right to 'jitter' as the slider is moved so I used a
PaddedForm and the Courier font to keep the number fixed width.

With the Presentations package we could stay with the default "Segoe UI"
font used in Panels and keep the width fixed by using
ProportionalNumberForm.


Needs["Presentations`Master`"]

DynamicModule[
 {RTT = .1},
 Panel[
  Column[
   {Row[
     {"Round Trip Time: ",
      Slider[Dynamic[RTT], {0.03, 0.25}, Appearance -> Small],
      Spacer[10],
      Dynamic@ProportionalNumberForm[Round[1000 RTT], 4], Spacer[2], 
      "ms"
      }](* Row *),
    Dynamic@
     Plot[Sqrt[2]/(RTT*Sqrt[p]), {p, .001, .1}, 
      PlotRange -> {{0, .1}, {0, 150}},
      ImageSize -> 400]}](* Column *),
  Style["Custom Dynamic Display", 16],
  BaseStyle -> {FontSize -> 14}
  ](* Panel *)
 ]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  



From: Damon [mailto:damonwischik at gmail.com] 

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?

Thanks,
Damon.




  • Prev by Date: Re: Reposted, Reformatted Re: "mapping" functions over lists, again!
  • Next by Date: Re: Dynamic changing of variables
  • Previous by thread: Re: Custom label for a slider in Manipulate
  • Next by thread: Re: Custom label for a slider in Manipulate