2
$\begingroup$

I have the following dialog to calculate the product of a and b:

CreateDialog[ Column[{InputField[Dynamic[a], Number, FieldHint -> "enter a"], InputField[Dynamic[b], Number, FieldHint -> "enter b"], Button["run", MessageDialog[ToString[a b]]], Button["Close", DialogReturn[]]}]];

Upon execution of this cell, it works exactly the way I need, giving this: enter image description here

Is there a way that this dialog appears without opening the notebook? I just want to double-click on the notebook file and see the front end and this dialog appearing. Any help appreciated!

$\endgroup$
  • $\begingroup$ No, I mean .nb. $\endgroup$ – Kuba Mar 31 '15 at 18:52
  • $\begingroup$ you mean save the dialog as a notebook that you subsequently click on and open directly? Try NotebookSave $\endgroup$ – Mike Honeychurch Mar 31 '15 at 22:58
3
$\begingroup$

Dialogs are notebooks with different from regular options settings, so you can export save them as you want:

(that is the case with palettes too)

Export[
 FileNameJoin[{$TemporaryDirectory, "myDialog.nb"}], 
 CreateDialog[ 
  Column[{
    InputField[Dynamic[a], Number, FieldHint -> "enter a"],             
    InputField[Dynamic[b], Number, FieldHint -> "enter b"], 
    Button["run", MessageDialog[ToString[a b]]], 
    Button["Close", DialogReturn[]]}]] 
]; 

SystemOpen @ $TemporaryDirectory
$\endgroup$
  • $\begingroup$ perfect... wow! Thanks! $\endgroup$ – Kurt Mar 31 '15 at 19:29

Your Answer

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

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