2010-08-24

Form style dialogs

When you are creating your user interfaces you often want to produce a pop up form.  The code below is not perfect in that when you close the form it asks you if you want to save but it is workable:

ReportUnderConstruction[] := NotebookPut[Notebook[{
    Cell["Report under construction", "Text"]
    }]]

testForm[] := DynamicModule[{},
  Column[{
    TextCell["Form", "Section"],
    Text@TextCell["Reconciliation 2010-08-24", "Subsection"],
    Text@TextCell["Sample controls to illustrate a dialog box.",
      "Text", FontColor -> Darker@Blue],
    Spacer[10],
    Button[Style["Show Report", FontFamily -> "Helvetica"],
     ReportUnderConstruction[]],
    Spacer[10],
    Button[Style["Reset Report", FontFamily -> "Helvetica"],
     ReportUnderConstruction[]],
    Spacer[10]
    }]]

Button["Form", nb = NotebookPut[Notebook[{
     Cell["testForm[]", "Input", CellOpen -> False]
     }]];
SelectionMove[nb, Next, Cell];
SelectionEvaluateCreateCell[nb]]

This looks like this:

image

When you click on the button you get the pop up form:

image

Those buttons then produce a very simple report:

image

No comments: