I have a GUI, built inside a DynamicModule. I would like to be able to load previous set options and values, changing the values that are currently set within the DynamicModule, not the global variables.

For instance, make a file containing 4 variables:

a = True; b = False; c = True; d = 100;
Save["test.mdx", {a, b, c, d}]
Clear[a, b, c, d]

Now I have a little Dynamic with a button, but the Get will load the variables into the general context. Is there a way to get it to replace the values within the DynamicModule?

DynamicModule[{a = False, b = True, c = False, d = 1},
 Row[{Checkbox[Dynamic[a]], Checkbox[Dynamic[b]], 
   Checkbox[Dynamic[c]], Spacer[10], Dynamic[d], 
   Button["Get Data", Get["test.mdx"]]}]

Other methods of locally importing a number of variables from a previous run are welcome. The number of saved variables may change, and won't be everything in the DynamicModule scope.

  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Kuba Nov 22 '18 at 19:59

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.