# How to show a general graphic (not a Plot) inside a Manipulate

I'm building a little interface, which consists only of a button, as you can see here:

Button["File Input",
file = Import[SystemDialogInput["FileOpen"]];
Print[principalFunction[file]]]


Now I'd like to insert the produced graphic and the button inside a Manipulate. Note that I'm not using Plot, Plot3D, etc. -- the graphics are produced by principalFunction as the final result of evaluating many other functions.

-
Instead of an image give us the code? Adapt it so we don't need the file? :) Or you can just provide the file as well. –  Öskå Apr 24 '14 at 13:54
ok, I've done what you asked –  Lory Lory Apr 24 '14 at 14:03
Try Module[{file = {0, 0}}, Panel[Column@{Button["File Input", file = ToExpression@Import[SystemDialogInput["FileOpen"], "Data"];], Dynamic@ListLinePlot@file}]]. The important parts here are Module, Panel (for the Manipulate-lookalike) and Dynamic for the update :) Works with a text file containing {{1,0},{1,1}}. –  Öskå Apr 24 '14 at 14:12

## 1 Answer

Not really a fancy answer but questions need to be answered and I hope this answers the (quite unclear) question.

As mentioned in the comments the important parts in the following codes are Module, Panel for the Manipulate lookalike and Dynamic for the update. Since you mentioned that you were not using Plot here is an example with a Graphic entity.

Module[{file = {{0, 0}}, r = 1},
Panel[Column@{
Button["File Input",file = ToExpression@
Import["http://pastebin.com/download.php?i=eaey3Ehk"]; r = .5;],
Dynamic@Graphics[Disk[#, r] & /@ file]}]]


In your case you would have principalFunction@file instead of Graphics[Disk[#, r] & /@ file] and file = Import[SystemDialogInput["FileOpen"]]; with the operations (such as ToExpression in my case) you need to in order to use your data after using Import.

Version with Manipulate (thus no Dynamic nor Panel):

Module[{file = {{0, 0}}, r = 1},
Manipulate[Graphics[Disk[#, r] & /@ file, ImageSize -> {200, 200}],
Button["File Input", file =
ToExpression@Import["http://pastebin.com/download.php?i=eaey3Ehk"];
r = .5;]]]

-
This was very helpful. Thank to you I've been able to help a mate...It's not clear to me the second example you wrote, the one with Manipulate but the first was successful! –  Lory Lory Apr 29 '14 at 15:05
I'm glad I could help :) –  Öskå Apr 29 '14 at 16:05