4

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

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
whiteSkar
  • 1,614
  • 2
  • 17
  • 30

1 Answers1

5

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.

William
  • 2,695
  • 1
  • 21
  • 33
  • 1
    Cool. Thanks! Now I have a follow up question. Do you know why the authors of tkinter made these two functions when one of the functions seems enough? – whiteSkar Nov 06 '15 at 03:13
  • 2
    I don't know. They were both [introduced](https://github.com/python/cpython/commit/e88b69d52b33ad67f459aec3f45c8436b9bb282f) by Fred Lundh in July 1997, so you probably should search for discussions involving that person in the mailing list archives prior to that date :) – William Nov 06 '15 at 03:40