Message Boards Message Boards

0
|
6022 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

Unexpected behaviour within Manipulate

Community Members As a part of a larger interface, I added a button within a Manipulate to display an specific picture. In order to explain better I have written the following code:

Manipulate[{f, name}, {{f, Graphics[Disk[]]}, 
  ControlType -> None}, {{name, "filename"}, ControlType -> None}, 
 Button["Imagen?", name = SystemDialogInput["FileOpen"]]]

I have initializated variables f and name with a circle and filename, respectively. At first, theses variables are display properly but filename does not updates after choosing a filename clicking on the button "Image?" I do not know why is this? Thanks for any help!

Jesus

3 Replies
Posted 11 years ago

I had not seen the reply when I wrote this. I don't see a delete button, so moderator, please delete this post.

The following may not be very helpful, but it does update the filename. I also had trouble overriding the initialization, so I didn't initialize it.

Clear["Global`*"];

Manipulate[
Row[{Graphics@Disk[],Graphics[Text[Dynamic[filename],{0,0}],
 ImageSize->{200}]}],
 Button["Imagen?",filename=SystemDialogInput["FileOpen"]]]
POSTED BY: Gary Palmer

David Thanks indeed! It works as you have explained.

Regards

Jesus

This is a classic problem! Buttons (and some other dynamic things) are set up by default to preempt other evaluations that may be underway but also to only assume that it will take a specific maximum amount of time. Generally when using SystemDialogInput and other things that will take longer than this, the action will time out and nothing then happens. This is all controlled by the Method Option to Button.

"With the default setting Method->"Preemptive", button actions are performed immediately, preempting any other evaluation, but are allocated only a limited time to complete."

So add

Method->"Queued"

to your Button and all should be well...

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract