Heiko Westphal wrote:
>
> Ich bin erst seit kurzem Mathematica-User, hoffe aber trotzdem, dass
> sich Einer erbarmt, mir zu helfen.
>
> Ich moechte gerne ein Notebook erstellen, dass mich auf "Knopfdruck"
> (Button) nach den Variablen abfragt; diese dann uebernimmt und das
> Notebook dann neu berechnet.
> Dabei sollen teilweise Ergebnisse in andere Variablen uebergeben werden,
> die dann in anderen Berechnungen (aber im selben Notebook) auftauchen.
>
> Desweiteren moechte ich gerne wissen ob eine Moeglichkeit besteht
> griechische Symbole oder Vaiable mit Index zu benutzen.
>
> Ein Beispiel-Notebook sehr, sehr nett.
>
> Mit bestem Dank im voraus
> und froehlichen Nikolaus
>
> Heiko Westphal
>
> ------------------------
Lieber Herr Westphal,
bitte probieren Sie untiges notebook mal aus.
Es ist nichts besonderes, aber vielleicht als
Ausgangspunkt hilfreich.
MfG,
Rolf Mertig
-----------------------------
Dr. Rolf Mertig
Mertig Research & Consulting
Mathematica training and programming
Amsterdam, The Netherlands
http://www.mertig.com
-----------------------------
Notebook[{
Cell[CellGroupData[{
Cell["Front End Template Maker", "Title"],
Cell["Experimental code by rolf@XXXXXXX.com", "Subtitle"],
Cell["Version 0.01 ; December 1998", "Subsubtitle"],
Cell[CellGroupData[{
Cell["FETemplate", "Section",
GeneratedCell->True],
Cell[CellGroupData[{
Cell["code", "Subsection"],
Cell["\<\
Options[FETemplate] =
{PromptCellStyle ->
{\"Subsection\", CellDingbat -> None, CellMargins -> {{8,
Inherited}, \
{2, 4}}, Editable -> False},
FETemplateNotebookOptions ->
{Background -> GrayLevel[0.8], ShowCellBracket -> False,
WindowElements -> {\"HorizontalScrollBar\", \"VerticalScrollBar\",
\
\"MenuBar\"},
WindowMargins -> {{Automatic, 1}, {Automatic, 2}}},
FETemplateTitle ->
Cell[\"Input Variables\", \"Subsection\", TextAlignment -> Center,
\
CellDingbat -> None,
Editable -> False], FETemplateButton ->
Cell[BoxData[GridBox[{{ButtonBox[StyleBox[\" OK \", \"Subtitle\"],
RuleDelayed[ButtonFunction, OKFunction[]]],
ButtonBox[StyleBox[\" Close \", \"Subtitle\", Rule[FontColor,
\
RGBColor[0.7, 0, 0]]],
RuleDelayed[ButtonFunction,
NotebookClose[ButtonNotebook[]]]],
ButtonBox[StyleBox[\" Help \", \"Subtitle\"],
RuleDelayed[ButtonFunction,
NotebookPut[$FETemplateHelp]]]}}]], \
\"Text\", Editable -> False,
Active -> True, ButtonBoxOptions ->
{ButtonEvaluator -> Automatic, Active -> True, Background -> \
RGBColor[0.13, 0.4, 0.4]},
TextAlignment -> Center]}; \
\>", "Input",
InitializationCell->True],
Cell["\<\
OKFunction[] := (Cases[First[NotebookGet[ButtonNotebook[]]],
Cell[BoxData[_], ___, TaggingRules :> {_ -> _String}, ___], -1]
/.
Cell[a_, ___, TaggingRules :> {_ -> s_String}, ___] :>
Append[ToExpression[s, StandardForm, Hold],
First[MakeExpression[a, \
StandardForm]]] /.
Hold -> Set; $ExtraFunction); \
\>", "Input",
InitializationCell->True],
Cell["\<\
$FETemplateHelp = Notebook[{Cell[\"Enter values into the white \
fields, then press the OK button\",
\"Text\"]}, WindowSize -> {FitAll, FitAll}]; \
\>", "Input",
InitializationCell->True],
Cell["\<\
FETemplate[{entries__String, r___}, opts___Rule] := \
FETemplate[{{entries, r}}, opts]; \
\>", "Input",
InitializationCell->True],
Cell["\<\
FETemplate[pr:{{_String, _String, ___}..}, opts___Rule] :=
Block[{but, title, nbo, promptcellstyle},
promptcellstyle = Sequence @@ Flatten[{PromptCellStyle /. {opts} /. \
Options[FETemplate]}];
but = FETemplateButton /. {opts} /. Options[FETemplate];
nbo = Sequence @@ Flatten[{FETemplateNotebookOptions /. {opts} /. \
Options[FETemplate]}];
title = FETemplateTitle /. {opts} /. Options[FETemplate];
NotebookPut[Notebook[Append[Prepend[Flatten[Table[{Cell[pr[[i,1]], \
promptcellstyle],
Cell[If[Length[pr[[i]]] === 2, BoxData[\"\"],
BoxData[pr[[i,3]]]], \
\"Input\",
TaggingRules -> {\"variable\" -> pr[[i,2]]}, CellFrame ->
True,
CellMargins -> {{9, Inherited}, {4, 0}}, Background -> \
GrayLevel[1],
CellTags -> \"EnterCell\"]}, {i, Length[pr]}]], title],
but], \
nbo,
WindowSize -> {FitAll, FitAll}]]]\
\>", "Input",
InitializationCell->True]
}, Open ]],
Cell[CellGroupData[{
Cell["Examples", "Subsection"],
Cell[CellGroupData[{
Cell[" 1", "Subsubsection"],
Cell["FETemplate[{\"var1\", \"x\", 4}]; ", "Input"],
Cell["x", "Input"],
Cell["\<\
After clicking on \"OK\", the variable x gets the value 4 (or \
whatever is put in place of 4).
In order to execute an extra function (after the assignment x=4), give a
\
value to $ExtraFunction.\
\>", "Text"],
Cell["\<\
For example, if you wish to evaluate the notebook with the
new input parameters, you could copy the following into an Input Cell
into \
your notebook:\
\>", "Text"],
Cell["\<\
diesesnotebook = InputNotebook[];
$ExtraFunction := (SelectionMove[diesesnotebook, All, Notebook]; \
SelectionEvaluate[diesesnotebook]); \
\>", "Text"],
Cell["To generate a button you can evaluate, e.g. :", "Text"],
Cell["\<\
CellPrint[Cell[BoxData[ButtonBox[StyleBox[
\\(enter var1\\), \"Section\"],
ButtonFunction :>
FETemplate[{\"var1\", \"x\", 4}],
ButtonEvaluator-> Automatic]],
NotebookDefault, Active -> True]]\
\>", "Input"]
}, Open ]],
Cell[CellGroupData[{
Cell[" 2", "Subsubsection"],
Cell["\<\
FETemplate[{{\"var1\", \"x\"}, {\"var2\", \"y\", \"42.6\"}, {\"var3\
\", \"z\", \"\\\"string\\\"\"}}]; \
\>", "Input"],
Cell["Here no default value for x is given.", "Text"],
Cell["InputForm[{x, y, z}]", "Input"]
}, Open ]]
}, Open ]]
}, Open ]]
}, Open ]]
},
FrontEndVersion->"X 3.0",
ScreenRectangle->{{0, 1152}, {0, 864}},
WindowSize->{548, 470},
WindowMargins->{{91, Automatic}, {Automatic, 79}},
Magnification->1
]
|