Is there a way to use "popup" with 2 buttons?

Asked by Parn Yin

What I want now is:
display a multi-lines message of settings and then ask user whether continue or not.

I know popup(text[, title]) can display a dialog box with "OK" button, but it seems that it can't display 2 buttons for choosing.
I know using input([text][, default]) can provide 2 buttons, but this dialog may make users confused. Because it's a dialog box for inputting and its title "Input" can't be changed.
http://doc.sikuli.org/globals.html#interacting-with-the-user

Excuse me, is there a way to use "popup" with 2 buttons?
If not, will this feature be added into a new version of Sikuli?
Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Parn Yin
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

The Java feature behind popup and input is JOptionPane.

To use it in Python:
import javax.swing.JOptionPane as JO

def myInput (title, msg):
    ret = JO.showConfirmDialog(null, msg, title, JO.YES_NO_OPTION);
    if (ret == JO.CLOSED_OPTION or ret == JO.NO_OPTION) {
      return false;
    }
    return true;

for more variants:
http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html

Revision history for this message
RaiMan (raimund-hocke) said :
#2

... again as real Python ;-)

def myInput (title, msg):
    ret = JO.showConfirmDialog(null, msg, title, JO.YES_NO_OPTION)
    if ret == JO.CLOSED_OPTION or ret == JO.NO_OPTION:
        return False
    return True

Revision history for this message
Parn Yin (pyin) said :
#3

Thank you my mentor RaiMan! Works!

as real Python :)
"null" in the code above should be replaced by "None".