summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-11-08 07:35:55 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-11-08 07:35:55 (GMT)
commit5361e9a54e76a36a8cae5f01b71edbd4f7543a06 (patch)
tree83f68cb155d93d5be9bd639ce53f42a925519ca3 /Lib/lib-tk
parenta346c092919af0f40b3df992103df9bb43d88331 (diff)
downloadcpython-5361e9a54e76a36a8cae5f01b71edbd4f7543a06.zip
cpython-5361e9a54e76a36a8cae5f01b71edbd4f7543a06.tar.gz
cpython-5361e9a54e76a36a8cae5f01b71edbd4f7543a06.tar.bz2
Patch #1351744: Add askyesnocancel helper for tkMessageBox.
Diffstat (limited to 'Lib/lib-tk')
-rw-r--r--Lib/lib-tk/tkMessageBox.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/lib-tk/tkMessageBox.py
index aff069b..d14ca86 100644
--- a/Lib/lib-tk/tkMessageBox.py
+++ b/Lib/lib-tk/tkMessageBox.py
@@ -102,6 +102,15 @@ def askyesno(title=None, message=None, **options):
s = _show(title, message, QUESTION, YESNO, **options)
return s == YES
+def askyesnocancel(title=None, message=None, **options):
+ "Ask a question; return true if the answer is yes, None if cancelled."
+ s = _show(title, message, QUESTION, YESNOCANCEL, **options)
+ # s might be a Tcl index object, so convert it to a string
+ s = str(s)
+ if s == CANCEL:
+ return None
+ return s == YES
+
def askretrycancel(title=None, message=None, **options):
"Ask if operation should be retried; return true if the answer is yes"
s = _show(title, message, WARNING, RETRYCANCEL, **options)
@@ -119,4 +128,5 @@ if __name__ == "__main__":
print "question", askquestion("Spam", "Question?")
print "proceed", askokcancel("Spam", "Proceed?")
print "yes/no", askyesno("Spam", "Got it?")
+ print "yes/no/cancel", askyesnocancel("Spam", "Want it?")
print "try again", askretrycancel("Spam", "Try again?")