Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.5K Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Creating a Yes/No dialog?

Posted 3 years ago

I am trying to create dialogs looking something like these (from another piece of software) enter image description here

After much searching the best I can come up with is this:

CreateDialog[
Grid[{
{"Would you like to look for a text file containing dissociation constants?","    "},
{Item[ChoiceButtons[{"Yes","No"}, {DialogReturn["Yes"]; DialogReturn["No"]}],Alignment -> Right],SpanFromLeft}}, Alignment -> Left]]

which shows as

enter image description here

My only problem is in determining which button has been pressed because DialogReturn["Yes"] doesn't work.

I never guessed it would be so difficult to get a simple Yes/No dialog!

POSTED BY: Paul Newton
6 Replies
Posted 3 years ago

Maybe ChoiceDialog?

ChoiceDialog[
  "Would you like to look for a text file containing dissociation constants?", 
  {"Yes, abolutely!" -> True, "I'd rather not" -> False}]

And if you would be satisfied with the standard "OK" and "Cancel" buttons, you could get away with just this:

ChoiceDialog["Would you like to look for a text file containing dissociation constants?"]
POSTED BY: Eric Rimbey
Posted 3 years ago

I believe I looked at ChoiceDialog but could not make it modal - if it can be made modal that would certainly be the way to go.

POSTED BY: Paul Newton
Posted 3 years ago
ChoiceDialog[
  "Would you like to look for a text file containing dissociation constants?", 
  {"Yes, abolutely!" -> True, "I'd rather not" -> False}, 
  Modal -> True]
POSTED BY: Eric Rimbey
Posted 3 years ago

Thank you, Eric. My only excuse is that on this page ChoiceDialog there is no mention of Modal whatsoever. I admit that there is probably something somewhere in the docs about using Modal with dialogs in general, but it is not immediately obvious.

My other gripe would be that, in order to make "No" the default option, you would have to swap the positions of the buttons (unless I am mistaken about that too).

POSTED BY: Paul Newton
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago

I take all your points and I am gradually becoming more comfortable with the docs. I will definitely bear in mind the Options function.

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