How to create a message box with tkinter?

messagebox, python, tkinter

Solution

You can use the module tkMessageBox for Python 2.7 or the corresponding version for Python 3 called `tkinter.messagebox`.

It looks like `askquestion()` is exactly the function that you want. It will even return the string `"yes"` or `"no"` for you.

Problem

I've been trying to build a fairly simple message box in tkinter that has "YES" and "NO" buttons. When I push the "YES" button internally it must go and write YES to a file. Similarly, when "NO" is pushed, NO must be written to a file. How can I do this?

Original source