Python Prompt Toolkit 3.0¶
Notice that this is the prompt_toolkit 3.0 documentation. It is mostly compatible with the 2.0 branch. The difference is that prompt_toolkit 3.0 requires at least Python 3.6. On the plus side, it uses asyncio natively (rather than it’s own event loop), and we have type annotations everywhere.
prompt_toolkit is a library for building powerful interactive command line and terminal applications in Python.
It can be a very advanced pure Python replacement for GNU readline, but it can also be used for building full screen applications.
- Syntax highlighting of the input while typing. (For instance, with a Pygments lexer.)
- Multi-line input editing.
- Advanced code completion.
- Selecting text for copy/paste. (Both Emacs and Vi style.)
- Mouse support for cursor positioning and scrolling.
- Auto suggestions. (Like fish shell.)
- No global state.
- Both Emacs and Vi key bindings.
- Reverse and forward incremental search.
- Works well with Unicode double width characters. (Chinese input.)
- Pure Python. Runs on all Python versions starting at Python 3.6. (Python 2.6 - 3.x is supported in prompt_toolkit 2.0; not 3.0).
- Runs on Linux, OS X, OpenBSD and Windows systems.
- Lightweight, the only dependencies are Pygments and wcwidth.
- No assumptions about I/O are made. Every prompt_toolkit application should also run in a telnet/ssh server or an asyncio process.
Have a look at the gallery to get an idea of what is possible.
A special thanks to all the contributors for making prompt_toolkit possible.
Table of contents¶
- Getting started
- Printing (and using) formatted text
- Asking for input (prompts)
- Hello world
- The PromptSession object
- Syntax highlighting
- Input validation
- Auto suggestion
- Adding a bottom toolbar
- Adding a right prompt
- Vi input mode
- Adding custom key bindings
- Other prompt options
- Prompt in an asyncio application
- Reading keys from stdin, one key at a time, but without a prompt
- Progress bars
- Building full screen applications
- Advanced topics