Message Boards Message Boards

how to make the following graphical interface?

Posted 11 years ago

Hello all, I write in this forum because I have many doubts as to make the following graphical interface, my idea is to do something like the following: interface

and that as input parameters are the first number and second number order to operate on them subsequently. The problem is that it is not how to bind the boxes with the button to make the operation brought. I have done pieces of code for such an idea but without any results, here is what I have done

a=InputFiled[ ];
b=Inputfield[ ];
Button["Calculate",Print[Plus[a,b]
CheckboxBar[{1}, {1 -> "Plus", 2 -> "Subtract", 3 -> "Times",4-> "Division"}]

I hope that somebody can say me how to make my idea reality because it is the first time that I am doing this in Mathematica and and am having many problems.

Thanks in advance.

POSTED BY: Luis Ledesma
3 Replies
Posted 11 years ago

Many thanks for your help Gustavo to solve my problem, I've tested the code and it works very well, excuse my ignorance but it is possible to do the same with "checkboxbar" because I do not work with this command, that command is used for anything else?

Thanks a lot again.

POSTED BY: Luis Ledesma
Posted 11 years ago

Try something like

CheckboxBar[Dynamic[x, (x = #[[{-1}]]) &], Range@5]

but now here the result is a list so you should take x[[1]] before applying it.

POSTED BY: Kuba Podkalicki
Posted 11 years ago

Many ways to do it. This is one:

DynamicModule[{f = Plus, a = 1, b = 1, c = 2},
 Column[
  {RadioButtonBar[Dynamic[f], {Plus, Subtract, Times, Divide}],
   Grid[
    {{InputField[Dynamic[a]],  "First Number"},
     {InputField[Dynamic[b]], "Second Number"},
     {InputField[Dynamic[c], Enabled -> False], "Result"}}],
   Button["Calculate", c = f[a, b]]}]]

calc

Buena suerte!

POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract