Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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.

share|improve this question
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
up vote 2 down vote accepted

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},
    Button["File Input",file = ToExpression@
      Import[""]; r = .5;],
    Dynamic@Graphics[Disk[#, r] & /@ file]}]]

enter image description here

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 = 
      r = .5;]]]
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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