]> granicus.if.org Git - python/commitdiff
Patch #1351744: Add askyesnocancel helper for tkMessageBox.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 8 Nov 2006 07:35:55 +0000 (07:35 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 8 Nov 2006 07:35:55 +0000 (07:35 +0000)
Lib/lib-tk/tkMessageBox.py
Misc/NEWS

index aff069bfa75a9f7337001e8f57a1a843f31fcb1f..d14ca86febc0bf592d5d3a9a18fc96b7efa50a5a 100644 (file)
@@ -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?")
index b5692081e921d8318f6e6052bf9b0d3416f0155a..3409c8dd71c1789bf1d64192ce1d1b34e180b86e 100644 (file)
--- 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