From: Martin v. Löwis Date: Wed, 8 Nov 2006 07:35:55 +0000 (+0000) Subject: Patch #1351744: Add askyesnocancel helper for tkMessageBox. X-Git-Tag: v2.6a1~2455 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5361e9a54e76a36a8cae5f01b71edbd4f7543a06;p=python Patch #1351744: Add askyesnocancel helper for tkMessageBox. --- diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/lib-tk/tkMessageBox.py index aff069bfa7..d14ca86feb 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?") diff --git a/Misc/NEWS b/Misc/NEWS index b5692081e9..3409c8dd71 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -96,6 +96,8 @@ Core and builtins Library ------- +- Patch #1351744: Add askyesnocancel helper for tkMessageBox. + - Patch #1060577: Extract list of RPM files from spec file in bdist_rpm