MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DialogInput in ButtonFunction

  • To: mathgroup at
  • Subject: [mg125711] Re: DialogInput in ButtonFunction
  • From: A Retey <awnl at>
  • Date: Thu, 29 Mar 2012 03:05:11 -0500 (EST)
  • Delivered-to:
  • References: <jku7t5$8jn$>

Am 28.03.2012 07:34, schrieb Jakob Ebner:
> I would like to impement something like the following into the
> function of a button which needs the returned value for further
> evaluation.
> DialogInput[{
>    InputField[Dynamic[dyn], String],
>    FileNameSetter[Dynamic[dyn]],
>    Button["Ok", DialogReturn[dyn]]
>    }]
> Now I encounter two problems:
> i) calling DialogInput or CreateDialog whithin a button causes my
> Mathematica session to crash.
 > ii) if this would work I also have the problem that the browse button
 > won`t work because the evaluation in the main notebook is halted.
 > Any Suggestions?

you need to set the Method of the Button to "Queued", that should save 
you from the crashes. AFAIK you also can't nest two modal dialogs, so 
when you insist on using FileNameSetter (which I tink calls such a 
dialog) then you can't use DialogInput. An alternative is to use 
CreateDialog and delay the Set (and all following code) to the 
DialogReturn, which will of course not be run when the user closes the 
window without clicking the OK button:

Button["set filename",
    InputField[Dynamic[dyn], String],
    Button["Ok", DialogReturn[filename = dyn]]
  Method -> "Queued"

of course you could just as well do:

Button["set filename",
   filename = SystemDialogInput["FileOpen"],
   Method -> "Queued"



  • Prev by Date: Re: Is there SphericalListPlot3D?
  • Next by Date: Re: Integers that are the sum of 2 nonzero squares in exactly 2 ways
  • Previous by thread: DialogInput in ButtonFunction
  • Next by thread: Re: DialogInput in ButtonFunction