0
$\begingroup$

For example, if I have this basic button

Button["Sum", Print[2 + 2]]

is it possible to overwrite the same output without creating a new one and have a single 4 printed out?

$\endgroup$
2
$\begingroup$

You can assign the result to a variable and access the variable dynamically, like:

Button["Sum 2+2", x = 2 + 2]
Button["Sum 2+5", x = 2 + 5]
Dynamic@x

Output:

x

(press first button)

4

(press second button)

7

$\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.