Dialog-type notebook

2

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!

Kurt

Posted 2015-03-31T18:44:04.333

Reputation: 47

No, I mean .nb. – Kuba – 2015-03-31T18:52:50.200

you mean save the dialog as a notebook that you subsequently click on and open directly? Try NotebookSave – Mike Honeychurch – 2015-03-31T22:58:36.277

Answers

3

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

Kuba

Posted 2015-03-31T18:44:04.333

Reputation: 129 207

perfect... wow! Thanks! – Kurt – 2015-03-31T19:29:10.817