0

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?

1 Answers1

2

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

Theo Tiger
  • 1,273
  • 8
  • 10