2
$\begingroup$

I would like to make a nice Interface of a simulation I wrote, but i don't know how.

I want that you run the code and then a window asking for input of some values appears (either in the same notebook or an additional window, I don't mind). There should be of course some Inputfields and a button that gives the option to set other values to, kind of advanced setting. If that button is not pushes, I want to transmit standard values for those. That can look like this: enter image description here

or like this: enter image description here

The codes for those results are

 DialogInput[
  DialogNotebook[{TextCell["Please enter value a:"], 
    InputField[Dynamic[a], Number], 
    TextCell["Please choose value b:"], 
    PopupMenu[Dynamic[b], {"x", "y", "z"}, String], "\n", 
    Grid[{{DefaultButton["further settings", 
        DialogInput[
         DialogNotebook[
          Grid[{{TextCell["Please enter value c:"], 
             InputField[Dynamic[c], Number]}, {TextCell[
              "Please enter value d:"], 
             InputField[Dynamic[d], Number]}, {DefaultButton[
              DialogReturn[{a, b, c, d}]], CancelButton[]}}]]]], 
       DefaultButton[DialogReturn[{a, b, c, d}]], , , 
       CancelButton[]}}]}]]; 

and

DynamicModule[{a = 0, b = 0, c = 15, d = 20}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{"Please enter value a: ", "Please choose value b: ", 
        "further settings :", 
        Button["OK", startCalculation[], 
         Method -> "Queued"]}, {InputField[Dynamic[a], Number], 
        PopupMenu[Dynamic[b], {1 -> "x", 2 -> "y", 3 -> "z"}, String],
         Button["further settings ", 
         DialogInput[
          DialogNotebook[
           Grid[{{TextCell["Please enter value c:"], 
              InputField[c, Number]}, {TextCell[
               "Please enter value d:"], 
              InputField[d, Number]}, {DefaultButton[
               DialogReturn[{a, b, c, d}]], CancelButton[]}}]]], 
         Method -> "Queued"], SpanFromLeft}}], Alignment -> Center], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{30, 30}, {1, Infinity}}}}]]];

respectively.

After the first Interface, the normal calculation starts. Since mathematica is waiting for the results of the Dialog, the only problem there is setting the further settings.

In the second Interface I do not know how to start the real calculation, since mathematica is finishing the evaluation after showing the Interface.

Unfortunately, I am already struggeling with this for days and neither I get those Interfaces working properly , nor I find good alternatives for what I want to do.

Does one has a hint how I can fix those Interfaces or knows a better way of doing one that fullfill my contraints?

$\endgroup$
  • $\begingroup$ Sorry I do not exactly get what you mean. Are you talking about the first or the second solution? What exactly should I close and open and where? Cheers $\endgroup$ – Stefan Sailer Apr 26 '16 at 12:12
  • $\begingroup$ Sorry I may have missed something but don't have more time now. Will try to be back later. Shortly, I don't think it is possible to open Kernel blocking dialog from within another kernel blocking dialog, you have to rearrange your work scheme. $\endgroup$ – Kuba Apr 26 '16 at 12:35
  • $\begingroup$ It doesn't necessarily need to look exactly like that. If it's possible to like expand the first dialog window, so that the additional fields appear when you push the button or similar that's also fine. I just want those further settings only to appear in case the button is pushed, if not they should have some fixed values. Is this possible somehow? Thanks for your help so far already! $\endgroup$ – Stefan Sailer Apr 26 '16 at 12:47
  • $\begingroup$ If you read the note under Details and Options in the documentation for DialogInput you will find that your interface design will not work because input dialogs are modal in Mathematica. $\endgroup$ – m_goldberg Apr 26 '16 at 12:47
  • 1
    $\begingroup$ The way I would do it would be to use a single dialog with a tab view (TabView) with one tab labeled Basic Settings and the other labeled More Settings. $\endgroup$ – m_goldberg Apr 26 '16 at 13:03

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.