5
$\begingroup$

Suppose I have a DialogInput, in which there is a Button. The Button can trigger another DialogInput. Then, according to documentation, I have to add Method->"Queued" to the Button to avoid time out.

However, blocking dialog such as DialogInput blocks queued evalutaion channel, which makes the Button disabled.

The following cases are for demonstration.

  1. DialogInput[Button["You have to wait after click", DialogInput[DialogReturn[1]]]] This works but you need to wait for minutes before the dialog prompts up.

  2. DialogInput[Button["Doesn't work", DialogInput[DialogReturn[1]], Method->"Queued"]] This does not work because the outer DialogInput blocks the queued evalutaion channel.

Now, if I want a DialogInput with a Button and the Button should trigger another DialogInput, what should I do?

$\endgroup$
7
  • $\begingroup$ It seems that you can't nest Kernel blocking dialogs. Maybe you could briefly describe the context so that we can find a work around? $\endgroup$
    – Kuba
    Commented Apr 1, 2016 at 18:14
  • $\begingroup$ @Kuba I am working on a questioning game. It's a Do loop. In each round a InputDialog shows with an InputField. When submitted, another ChoiceDialog prompts to ask the user to confirm the answer. In the ChoiceDialog, there is a button which can trigger an InputDialog for the user to change the answer. $\endgroup$
    – Louis Yu
    Commented Apr 3, 2016 at 6:52
  • $\begingroup$ Try nesting CreateDialog inside DialogInput $\endgroup$ Commented Apr 5, 2016 at 21:06
  • $\begingroup$ @Algohi Could you provide an example? Louis, is my answer of any help for you? $\endgroup$
    – Kuba
    Commented Apr 6, 2016 at 13:50
  • $\begingroup$ @Kuba, I did not post an answer because I don't have a complete answer to this question. I am myself facing same problem for long time ago and I am still living with that problem. what I am doing in my case is something like this (next comment) however if you run this code you will see that if you get value of y and press OK then the kernel is released before the main dialog box is closed. I would like to know your suggestion for this. Thanks $\endgroup$ Commented Apr 6, 2016 at 14:43

1 Answer 1

1
$\begingroup$

I think there is no general/stable way to prompt kernel blocking dialog from another kernel blocking dialog.

answerPrompt[] := Input["Give me the answer please."];
confirmationPrompt[] := ChoiceDialog["Are you sure?"];

You don't need to do that though. Use the code below in your Do loop to answer and confirm questions:

While[
 answer = answerPrompt[];
 Not @ TrueQ @ confirmationPrompt[]
 ]

answer
$\endgroup$
3
  • $\begingroup$ Sorry for the late reply. But your code cannot be used in my case. Because there are some other taskes being processed in ChoiceDialog, it can not be released that early. $\endgroup$
    – Louis Yu
    Commented Apr 6, 2016 at 15:38
  • $\begingroup$ To be specific, what I am doing is a English word memorizing helper. In the input dialog I enter the meaning and then I compare it with the answer in the ChoiceDialog. The choice can be right or wrong or partial. My choice will be sent to a machine learning subroutine to analyze for future prediction. In the ChoiceDialog there are translations getting from some online dictionary API. However, that translations mat be wrong or redundant, so I may want to edit it. $\endgroup$
    – Louis Yu
    Commented Apr 6, 2016 at 15:39
  • $\begingroup$ Actually I can edit it in my database but it would be much more convenient if I can edit in that ChoiceDialog, since I will not have to reload those data and continue to answer questions in the next loop. $\endgroup$
    – Louis Yu
    Commented Apr 6, 2016 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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