Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9285
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: DialogInput in ButtonFunction |
| Date | 2012-03-29 08:10 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jl15de$lgd$1@smc.vnet.net> (permalink) |
| References | <jku7t5$8jn$1@smc.vnet.net> |
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",
CreateDialog[{
InputField[Dynamic[dyn], String],
FileNameSetter[Dynamic[dyn]],
Button["Ok", DialogReturn[filename = dyn]]
}],
Method -> "Queued"
]
of course you could just as well do:
Button["set filename",
filename = SystemDialogInput["FileOpen"],
Method -> "Queued"
]
hth,
albert
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
DialogInput in ButtonFunction Jakob Ebner <jakob.ebner@gmail.com> - 2012-03-28 05:34 +0000 Re: DialogInput in ButtonFunction A Retey <awnl@gmx-topmail.de> - 2012-03-29 08:10 +0000 Re: DialogInput in ButtonFunction John Fultz <jfultz@wolfram.com> - 2012-03-30 09:40 +0000
csiph-web