I have put together a function of the form:

InteractiveInitialGuess[parametersymbols_, initialParamGuesses_] := 
  Module[{plot, workingparams = Symbol["working" <> ToString[#]] & /@ 
          parametersymbols, returnvals}, 
    plot = NicePlot[xptData, integratedfn[xptData\[Transpose][[1]], 
    Panel[Row[{Column[Join[parameterSelector @@@ ({workingparams, 
                           {Button["Recalculate", plot = NicePlot[xptData, 
                            Button["Done", SelectionMove[EvaluationCell[], 
                                                         All, Cell]; 
                                           returnvals = workingparams; 

The basic idea is that I have a set of parameters that I want to set (using dynamic modules defined by parameterSelector). I click a button to recalculate a graph (defined by the function NicePlot--the calculation is a numerical integration of coupled differential equations, and as such, they take too long to update on-the-fly, hence the button-to-recalculate approach). And when I am done, I want to replace the dynamic interface with the final plot and return the selected values. I seem to have all of that working except for the returning of the values. Any advice would be appreciated!

Implementation example:

enter image description here

I recognize that I have not provided fully-functional code. If that's really necessary for this question, I am happy to provide it, but it seems like a straightforward enough question that such code may not be necessary.

(Side note: It does appear that there is a calculation error in the model, because the strange hump around 1 ms shouldn't be there, but the question I am asking here should be independent of that issue.)

  • 2
    $\begingroup$ What do you mean "return a value"? This Dynamic is occuring in the FE. If you want a value returned from a function like this you'll want to use DialogInput or such. $\endgroup$
    – b3m2a1
    Commented May 10, 2019 at 1:45
  • 1
    $\begingroup$ While context matters it helps to have a simple example to show the problem and the description of what exactly is the desired behavior. $\endgroup$
    – Kuba
    Commented May 10, 2019 at 9:21
  • $\begingroup$ The basic idea is that I want to settle on some initial parameter values interactively through this panel, but when I have made the determination, I want the interactivity to be overwritten (to remove the overhead on the kernel—which I already accomplished using Paste), but also do a standard function return. So if I enter results=InteractiveInitialGuess[params,initGuesses], when Done is clicked, a list of the decided-upon parameter values will be assigned to the variable “result.” $\endgroup$ Commented May 10, 2019 at 16:52
  • $\begingroup$ Hmmm. I suppose I could add another input field allowing the user to enter a symbol name for the results to be assigned to. Then upon a button-press, the results are assigned to that symbol. $\endgroup$ Commented May 10, 2019 at 17:01
  • $\begingroup$ And that works for me. It doesn't address the original question, but I like this solution even better. $\endgroup$ Commented May 10, 2019 at 17:34

1 Answer 1


I added this in between my other two buttons:

Row[{Button["Assign values to:", 
       ToExpression[resultsLabel, StandardForm, 
       Function[name, name = workingparams, HoldFirst]]], 
     InputField[resultsLabel, String]}]

This is an even better solution, because it allows me to save different parameter selections to more than one symbol without having to start over each time.

  • 1
    $\begingroup$ I appreciate your enthusiasm and I recognize that your problems are real and applicable to wider audience but without a simple example that anyone can run and the answer which addresses such example the topic is useful only for you. Please take a look at: what-do-we-mean-by-a-self-contained-minimal-working-example $\endgroup$
    – Kuba
    Commented May 11, 2019 at 7:18
  • $\begingroup$ Thank you for the criticism. I understand the utility of a self-contained minimal working example; when I was trying to construct one, I was having a very hard time making one that didn't remove some of the levels of complexity that might figure in to developing an answer to the question (e.g., I didn't know if the various levels of Dynamics were relevant or not). I will in the future try harder, however. Again, thank you for the constructive criticism. $\endgroup$ Commented May 11, 2019 at 18:41

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.