Message Boards Message Boards

2 Replies
0 Total Likes
View groups...
Share this post:

How to call functions using GUIKit taking input arguments interactively?

Dear all A quick question on the ability to pass parameters to functions from mathematic GUI in an interactive manner. I am using the GUIKit which offers great functionality for quick GUI interface building. I am trying to call a set of functions by clicking a button which I did and works. In addition I would like to pass parameters to those functions from the same GUI interface via clicking a drop-down menu,a checkbox or radiobutton for example. The idea is that because I have several set of functions and each has different arguments, it is convenient to offer the user the ability to select a set of those parameters to pass for calculations and then click evaluate button. Also note that some functions rely on the output from previous functions which I would like to account for in building the GUI. The problem is I can't figure a way to make the Widget checkbox function to do that. below is my attempts along with some example code

let's say I have three simple functions

add[a_, b_] := sum = a + b;
prod[a_, b_] := product = a*b;
divide[a_, b_] := division = a/b;

Now I wan't to call them using a bottom in a GUI graphical interface :

 Widget["Button", {"text" -> "Evaluate!",
      Script[Print[add[a, b]]]],
    Script[Print[prod[a, b]]]],
    Script[Print[divide[product, b]]]]
  ], IncludedScriptContexts -> {$Context}

which when providing:

a = 50; b = 5;

Note I pass the output from the prod function ( that is product) as input to the divide function. By running above code you get: enter image description here

Now my question is how can I adda checkbox or radio button for each input variable (a,b,c) with a list of possible values to pass to the functions interactively within this GUI interface. The conditions is I want that to be in the same GUI e.g. in a GUIKIt Widget Frame

Many thanks


POSTED BY: Hassan Hamdoun
2 Replies

I have moved on to use Manipulate instead. It is much better for GUIs than GUIKit which is a bit old now.

POSTED BY: Hassan Hamdoun

I also know that using checkbox I can selecting different values of variable a for example by alternating the check box e.g.:

   {"value of a", Checkbox[Dynamic[a], {10, -10, 100, 150, -50}], 

resulting in

enter image description here

The issue with this is that it still doesn't work with GUIRunModal??

POSTED BY: Hassan Hamdoun
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract