0
$\begingroup$

I would like to create a button which has the action of storing a numerical input. Is this possible?

For example, a button which I click, then enter "5", produces the result the the number 5 gets stored somewhere based on which button I clicked.

$\endgroup$
  • 1
    $\begingroup$ This is not a well posed question -- "stored somewhere" is too vague and so is "enter '5'". Please edit the question to give more details. Do not post the additional details in a comment. $\endgroup$ – m_goldberg Dec 7 '17 at 0:34
3
$\begingroup$

Try this for a simple approach:

{SetterBar[Dynamic[x], Range[10]], Dynamic[x]}

or if you want to compute a simple function of your number:

{SetterBar[Dynamic[x], Range[10]], Dynamic[x], Dynamic[N[Cos[x]]]}

If you want it to look nice:

Column[{SetterBar[Dynamic[x], Range[10]], 
       Dynamic[x], 
       Dynamic[N[Cos[x]]]}, Center]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.