← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #251638]: Creating confirmation dialogue

 

Question #251638 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/251638

RaiMan proposed the following answer:
Here you are:

# this is the pythonized version how popAsk is implemented in the version 1.1.0
def popAsk(msg, title = None):
    import javax.swing.JOptionPane as JOP
    if not title: 
        title = "... something to decide!"
    ret = JOP.showConfirmDialog(None, msg, title, JOP.YES_NO_OPTION)
    if ret == JOP.CLOSED_OPTION or ret == JOP.NO_OPTION:
        return False;
    return True

# usage
if popAsk("test"):
    print "User said YES"
else:
    print "User said NO or closed dialog"

# usage with a special dialog title
if popAsk("test", "... please decide"):
    print "User said YES"
else:
    print "User said NO or closed dialog"

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.