Re: InputString prompts
- To: mathgroup at smc.vnet.net
- Subject: [mg17401] Re: InputString prompts
- From: "P.J. Hinton" <paulh>
- Date: Thu, 6 May 1999 02:44:15 -0400
- Organization: "Wolfram Research, Inc."
- Sender: owner-wri-mathgroup at wolfram.com
On Mon, 3 May 1999, in article <7gfsol$6gf at smc.vnet.net>, Kristen Rounds
<krounds at accessone.com> writes:
> I would like to customize the prompt for an InputString to display 3
> matrices, as well as a text statement. This is my code as is:
>
> terma=InputString["Which term of the A matrix to change"];
>
> I would like to add the display of
> MatrixForm[A1x],MatrixForm[A1y],MatrixForm[A1z] to the question "Which
> term of the A matrix to change". Is there a way to do this?
No, you can't display two-dimensional typeset text in the label of an
Input[] generated dialog. However, you can use notebook manipulation
commands to display this type of prompt within a smaller notebook that
acts as a dialog box.
notebookDialog[inputPrompt_String, labelBoxes_] :=
Module[{nbObj},
nbObj = NotebookPut[
Notebook[{Cell[TextData[inputPrompt], "Text"],
Cell[BoxData[labelBoxes], "DisplayFormula"],
Cell[BoxData[RowBox[{"\[Placeholder]"}]], "Text",
CellTags -> {"text field"}],
Cell[BoxData[
ButtonBox["OK",
ButtonFunction :>
FrontEndExecute[{FrontEnd`NotebookLocate["text field"];
FrontEndToken["Copy"];
NotebookClose[ButtonNotebook[],
Interactive -> False]}], ButtonEvaluator -> None,
ButtonFrame -> "DialogBox"]], "Text" , Active -> True]},
WindowSize -> {FitAll, FitAll}]];
While[MemberQ[Notebooks[], nbObj], Sleep[1]];
SelectionMove[ClipboardNotebook[], All, Notebook];
ToExpression[
NotebookRead[ClipboardNotebook[]] /.
Cell[BoxData[boxes_], __, ___] -> boxes]]
Here is an example of its usage:
A1x = Array[Ax,{2,2}]
A1y = Array[Ay,{2,2}]
A1z = Array[Az, {2,2}]
notebookDialog["Which term of the A matrix to change",
ToBoxes[MatrixForm /@ {A1x, A1y,A1z}]]
Note that you have to convert your displayed expression into boxes.
If you have trouble getting valid results from ClipboardNotebook[], let me
know, and I will post an alternative method for getting the data out of
the dialog box notebook.
--
P.J. Hinton
Mathematica Programming Group paulh at wolfram.com
Wolfram Research, Inc. http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.