summaryrefslogtreecommitdiffstats
path: root/examples/abortaction.retry.py
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2015-10-05 02:24:44 +0200
committerJonathan Slenders <jonathan@slenders.be>2015-10-05 02:24:44 +0200
commite200a28c2f641099af7cffa4c03b3490d1ff61d3 (patch)
treef99b69fe4e12d4ef591160c3099e0b70c19e84f2 /examples/abortaction.retry.py
parent32d39ffce1afd22f312ead5c2f3bd2626b21e7e4 (diff)
Added abortaction.retry.py example.
Diffstat (limited to 'examples/abortaction.retry.py')
-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)