1
$\begingroup$

In Mathematica, InputFields and Sliders that are connected to Dynamics will change their values if the variable they control is changed procedurally. In Wolfram Cloud, only the first Dynamic in a notebook seems to behave this way. In this example,

Grid@{{"a =", InputField[Dynamic[a], Number], 
   Slider[Dynamic[a], {0, 1}]}, {"b =", 
   InputField[Dynamic[b], Number], Slider[Dynamic[b], {0, 1}]}}

a = 0.25;
b = 0.75;
Print["a = ", a, " b = ", b];

The InputFields and Sliders interact properly. But if I then execute this:

a = 0.75;
b = 0.25;
Print["a = ", a, " b = ", b];

The InputField and Slider associated with variable a update to the new value, but the ones for b do not.

Is there something I'm doing wrong? I'm trying to set up a user interface that consists of InputFields that can be changed interactively, but that can also be set to a number of known value sets procedurally. It works as desired in Mathematica.

$\endgroup$
  • $\begingroup$ Try Print["a = ", Dynamic@a, " b = ", Dynamic@b]; $\endgroup$ – M.R. Mar 25 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.