pythontkintertkmessagebox

What is the difference between 'askquestion' and 'askyesno' in tkinter?


What is the difference between the askquestion() and askyesno() functions of messagebox in Tkinter?

I found those two functions in this website: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/tkMessageBox.html


Solution

  • From the source:

    def askquestion(title=None, message=None, **options):
        "Ask a question"
        return _show(title, message, QUESTION, YESNO, **options)
    
    def askyesno(title=None, message=None, **options):
        "Ask a question; return true if the answer is yes"
        s = _show(title, message, QUESTION, YESNO, **options)
        return s == YES
    

    Thus, the difference is that askquestion will return YES or NO, meanwhile askyesno will return a boolean.