When executing Button ["Print" Print[1]] you get a button that, if pressed, prints to the screen 1. What I would like to have is button that performs a set of operations. As a minimal example -- pressing the Button ["Plot", Plot[x^3, {x,-1,1}] -- you get this plot. Is it possible ?
Asked
Active
Viewed 80 times
1
1 Answers
2
Is this what you want?
doStuff := Module[{}, (* do stuff *)];
Button["Do stuff", doStuff]
Here you can put whatever you want in doStuff.
Marius Ladegård Meyer
- 6,805
- 1
- 17
- 26
doStuff := Module[{}, Print[x^3, {x,-1,1}]]; Button["Do stuff", doStuff]... then clicking on the button I see no graphic. :( – Aug 16 '15 at 19:46Plot[x^3, {x,-1,1}]I assume. JustPrintit:doStuff := Module[{}, Print[Plot[x^3, {x,-1,1}]]]works fine for me. – Marius Ladegård Meyer Aug 16 '15 at 22:41