1
$\begingroup$
Rey[v_, roh_, dia_, muh_] := (roh*v*dia)/muh;
nu[pr_, re_] := pr*re;

Manipulate[
 Row[{
   StringJoin["Re:", ToString[Style[Rey[v, roh, dia, muh], 20]]],
   StringJoin["Nu:", ToString[Style[nu[pr, re], 14]]]}
  ],
 Text[Style["Re & Nu number calculator", 16]],
 Delimiter,
 {{v, 1.5, "Ve "}, ControlType -> InputField, FieldSize -> 5},
 {{roh, 1, "roh "}, ControlType -> InputField, FieldSize -> 5},
 {{dia, 0.01, "D"}, ControlType -> InputField, FieldSize -> 5},
 {{muh, 0.00089, "Vis "}, ControlType -> InputField, FieldSize -> 5},
 {{pr, 1.5, "Pr "}, ControlType -> InputField, FieldSize -> 5},
 {{re, 1000, "Ld "}, ControlType -> InputField, FieldSize -> 5},
 Delimiter,
 Item[Button["Calculate", Nothing, BaseStyle -> {15}]],
 LabelStyle -> {14}, ContentSize -> 200,
 TrackedSymbols :> All
]

The above code displays the Re and Nu values based on the user's inputs. I need to add two features to this dashboard:

  1. Add a radio button to select whether to display Re or Nu.
  2. The last two input fields, Pr and Ld, are only used to calculate Nu, so I would like to display them only when the user presses the Nu button.
$\endgroup$

1 Answer 1

4
$\begingroup$

It looks like the first four inputs only apply to Re, so it seems like you would want to only show those when the user selects "Re". Maybe I misunderstood, but here's an attempt:

Manipulate[
  Switch[
    displayChoice,
    "Re", StringJoin["Re:", ToString[Style[Rey[v, roh, dia, muh], 20]]],
    "Nu", StringJoin["Nu:", ToString[Style[nu[pr, re], 14]]]],
  Text[Style["Re & Nu number calculator", 16]],
  Delimiter,
  TabView[
    {{"Re",
      "Re" ->
        Column[
          {Control[{{v, 1.5, "Ve "}, ControlType -> InputField, FieldSize -> 5}],
           Control[{{roh, 1, "roh "}, ControlType -> InputField, FieldSize -> 5}],
           Control[{{dia, 0.01, "D"}, ControlType -> InputField, FieldSize -> 5}],
           Control[{{muh, 0.00089, "Vis "}, ControlType -> InputField, FieldSize -> 5}]}]},
     {"Nu",
      "Nu" ->
        Column[
          {Control[{{pr, 1.5, "Pr "}, ControlType -> InputField, FieldSize -> 5}],
           Control[{{re, 1000, "Ld "}, ControlType -> InputField, FieldSize -> 5}]}]}},
    Dynamic[displayChoice]],
  LabelStyle -> {14}, 
  ContentSize -> 200, 
  TrackedSymbols :> All, 
  ControlPlacement -> {Top, Left}]
$\endgroup$
1
  • $\begingroup$ Thanks, Lericr, Can we do that with Radio button? $\endgroup$
    – ASHISH
    Commented Aug 4, 2022 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.