In Mathematica I am trying to implement algorithm, for which I would like to have user friendly interface, I have managed to create Panel using Widgets, but when I am trying to provide the value of the textfield with clicking the Submit button, nothing happen.
I have created the following event:
BindEvent["action", Script[buttonClicked[]]
so when the button is clicked buttonClicked[] should be executed, which contains check on the textfield. But nothing happen when clicking Submit. Could you please give me a hand on that.
Needs["GUIKit`"];
ref = GUIRun[Widget["Panel",
{Widget[
"Label", {"text" ->
"Please provide the following coefficients:"},
WidgetLayout -> {"Alignment" -> Center}, Name -> "mainLabel"],
WidgetSpace[10],
{Widget["Label", {"text" -> " Value for p1"}],
Widget["TextField", {"columns" -> 6}, Name -> "p1_tf"],
Widget["Label", {"text" -> " "}]
},
WidgetSpace[10],
{WidgetFill[],
Widget["Button", {"text" -> "Submit",
BindEvent["action", Script[buttonClicked[]]]},
Name -> button1], WidgetFill[]
}
}
]]
ImaginaryQ[expr_] := ! FreeQ[expr, _Complex];
Script[
buttonClicked[] := (If [
ImaginaryQ@p1_tf ==
False, {MessageDialog [
"The provided value is not valid. You need to enter complex value"], Exit[]}];)
]
GUIScreenShot[ref];
p[[1]] = p1_tf; (*p1*)
Print["p1=", p[[1]]];
GUI*
are part of the GUIKit which is still available in v.8. $\endgroup$ – rcollyer May 14 '12 at 14:29Manipulate
andDynamic
available. $\endgroup$ – rcollyer May 14 '12 at 17:43