summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xexamples/abortaction.retry.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/abortaction.retry.py b/examples/abortaction.retry.py
new file mode 100755
index 00000000..0ad3d598
--- /dev/null
+++ b/examples/abortaction.retry.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+"""
+Demontration of the RETRY option.
+
+Pressing Control-C will not throw a `KeyboardInterrupt` like usual, but instead
+the prompt is drawn again.
+"""
+from __future__ import unicode_literals
+from prompt_toolkit import prompt, AbortAction
+
+
+if __name__ == '__main__':
+ answer = prompt('Give me some input: ', on_abort=AbortAction.RETRY)
+ print('You said: %s' % answer)