MathGroup Archive 2007

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

Search the Archive

DynamicModule - a few questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81470] DynamicModule - a few questions
  • From: "Maarten van der Burgt" <maarten.vanderburgt at icos.be>
  • Date: Wed, 26 Sep 2007 06:21:40 -0400 (EDT)

Dear all,

Below an example from the on-line help of DynamicModule, which I modified
slightly to produce the quotient in the 4th InputField line.

I have to seemingly simple questions:
1. How do I limit the number of digits after the decimal sign to 2 in the
'inputfield' for the quotient.
     - Round[100. a/ b]/100. is such an ugly contstruction and sometimes
produces number like 1.2300000000001`
     - NumberForm[a/b,{100,2}] limits the number of digits after the
decimal sign indeed to 2, but resuls in "" around the number.
2. The natural thing to do when entering a number in one of the inputfield
is to press Enter. This produces a 2nd dynamic window. How to prevent this
(the same happens with most results from Manipulate etc.)

Thanks for your help,

Maarten


DynamicModule[{a = 1., b = 3.},
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["input a number", Red],
        Style["input another number", Red], "here is their sum",
        "their difference",
        "their quotient"}, {InputField[Dynamic[a], Number],
        InputField[Dynamic[b], Number],
        InputField[Dynamic[a + b], Enabled -> False],
        InputField[Dynamic[a - b], Enabled -> False],
        InputField[Dynamic[a/ b // N], Enabled -> False]}}],
     Alignment -> Right], ImageMargins -> 10],
   DefaultOptions -> {InputField -> {ContinuousAction -> True,
       FieldSize -> {{5, 30}, {1, Infinity}}}}]]]



  • Prev by Date: RE: Re: Mathematica 6.0 - FinancialData
  • Next by Date: animated GIF
  • Previous by thread: Re: making a list using table but with different increment after a certain number
  • Next by thread: animated GIF