NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #159 most downloaded on PyPI
Library for building powerful interactive command lines in Python
Last release 2 months ago
26 Jul 2026
Ships fairly regularly
a new release about every 4 months
Nearly every release is documented
notes for 56 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
137 releases · first in 2014
Backwards incompatible changes:
Bug fixes:
TextArea. Set accept_handler to None if not given.default argument of the prompt function when called multiple
times.history in prompt() function again.Backwards incompatible changes:
PipeInput to PosixPipeInput. Added Win32PipeInput and
create_input_pipe.buffer argument to the accept_handler of TextArea.New features:
accept_default argument to prompt().DynamicContainer.merge_completers for merging multiple completers together.One column per quarter.
Fix in 'x' and 'X' Vi key bindings. Correctly handle line endings and args.
Bug fixes:
Python 3.7 support: correctly handle StopIteration in asynchronous generator.
Bug fixes:
…of the buffers dictionary. This introduces many backwards incompatible changes, but the result is a very nice and powerful architecture.
Version 2.0 includes a big refactoring of the internal architecture. This includes the merge of the CommandLineInterface and the Application object, a rewrite of how user controls are focused, a rewrite of how event loops work and the removal of the buffers dictionary. This introduces many backwards incompatible changes, but the result is a very nice and powerful architecture.
Most architectural changes effect full screen applications. For applications
that use prompt_toolkit.shortcuts for simple prompts, there are fewer
incompatibilities.
Changes:
No automatic translation from \r into \n during the input processing. These
are two different keys that can be handled independently. This is a big
backward-incompatibility, because the Enter key is ControlM, not
ControlJ. So, now that we stopped translating \r into \n, it could be that
custom key bindings for Enter don't work anymore. Make sure to bind
Keys.Enter instead of Keys.ControlJ for handling the Enter key.
The CommandLineInterface and the Application classes are merged. First,
CommandLineInterface contained all the I/O objects (like the input, output
and event loop), while the Application contained everything else. There was
no practical reason to keep this separation. (CommandLineInterface was
mostly a proxy to Application.)
A consequence is that almost all code which used to receive a
CommandLineInterface, will now use an Application. Usually, where we
had an attribute cli, we'll now have an attribute app.
Secondly, the Application object is no longer passed around. The get_app
function can be used at any time to acquire the active application.
(For backwards-compatibility, we have aliases to the old names, whenever possible.)
prompt_toolkit no longer depends on Pygments, but it can still use Pygments for its color schemes and lexers. In many places we used Pygments "Tokens", this has been replaced by the concept of class names, somewhat similar to HTML and CSS.
PygmentsStyle and PygmentsLexer adaptors are available for
plugging in Pygments styles and lexers.
Wherever we had a list of (Token, text) tuples, we now have lists of
(style_string, text) tuples. The style string can contain both inline
styling as well as refer to a class from the style sheet. PygmentsTokens
is an adaptor that converts a list of Pygments tokens into a list of
(style_string, text) tuples.
Changes in the Style classes.
style.from_dict does not exist anymore. Instantiate the Style class
directory to create a new style. Style.from_dict can be used to create
a style from a dictionary, where the dictionary keys are a space separated
list of class names, and the values, style strings (like before).
print_tokens was renamed to print_formatted_text.
In many places in the layout, we accept a parameter named style. All the
styles from the layout hierarchy are combined to decide what style to be
used.
The ANSI color names were confusing and inconsistent with common naming conventions. This has been fixed, but aliases for the original names were kept.
The way focusing works is different. Before it was always a Buffer that
was focused, and because of that, any visible BufferControl that contained
this Buffer would be focused. Now, any user control can be focused. All
of this is handled in the Application.layout object.
The buffers dictionary (CommandLineInterface.buffers) does not exist
anymore. Further, buffers was a BufferMapping that keeps track of which
buffer has the focus. This significantly reduces the freedom for creating
complex applications. We wanted to move toward a layout that can be defined
as a (hierarchical) collection of user widgets. A user widget does not need
to have a Buffer underneath and any widget should be focusable.
layout.Layout was introduced to contain the root layout widget and keep
track of the focus.The key bindings were refactored. It became much more flexible to combine sets of key bindings.
Registry has been renamed to KeyBindings.add_binding function has been renamed to simply add.load_* function returns one KeyBindings objects, instead of
populating an existing one, like before.ConditionalKeyBindings was added. This can be used to enable/disable
all the key bindings from a given Registry.merge_key_bindings was added. This takes a list of
KeyBindings and merges them into one.key_binding.defaults.load_key_bindings was added to load all the key
bindings.KeyBindingManager has been removed completely.input_processor was renamed to key_processor.Further:
Key class does not exist anymore. Every key is a string and it's
considered fine to use string literals in the key bindings. This is more
readable, but we still have run-time validation. The Keys enum still
exist (for backwards-compatibility, but also to have an overview of which
keys are supported.)User controls can define key bindings, which are active when the user control is focused.
UIControl got a get_key_bindings (abstract) method.Changes in the layout engine:
LayoutDimension was renamed to Dimension.VSplit and HSplit now take a padding argument.VSplit and HSplit now take an align argument.
(TOP/CENTER/BOTTOM/JUSTIFY) or (LEFT/CENTER/RIGHT/JUSTIFY).Float now takes allow_cover_cursor and attach_to_window arguments.Window got an WindowAlign argument. This can be used for the alignment
of the content. TokenListControl (renamed to FormattedTextControl) does
not have an alignment argument anymore.Window, got a style argument. The style for
parent containers propagate to child containers, but can be overridden.
This is in particular useful for setting a background color.FillControl does not exist anymore. Use the style and char arguments
of the Window class instead.DummyControl was added.PromptMargin now takes line_number and
is_soft_wrap as input.Changes to BufferControl:
The InputProcessor class has been refactored. The apply_transformation
method should now takes a TransformationInput object as input.
The text (reverse-i-search) is now displayed through a processor. (See
the shortcuts module for an example of its usage.)
widgets and dialogs modules:
A small collection of widgets was added. These are more complex collections
of user controls that are ready to embed in a layout. A shortcuts.dialogs
module was added as a high level API for displaying input, confirmation and
message dialogs.
Every class that exposes a __pt_container__ method (which is supposed
to return a Container instance) is considered a widget. The
to_container shortcut will call this method in situations where a
Container object is expected. This avoids inheritance from other
Container types, but also having to unpack the container object from
the widget, in case we would have used composition.
Warning: The API of the widgets module is not considered stable yet, and can change is the future, if needed.
Changes to Buffer:
Buffer no longer takes an accept_action. Both AcceptAction and
AbortAction have been removed. Instead it takes an accept_handler.Changes regarding auto completion:
ThreadedCompleter in order to get asynchronous autocompletion.Changes regarding input validation:
Validator.from_callable class method for easy creation of
new validators.Changes regarding the History classes:
History base class has a different interface. This was needed for
asynchronous loading of the history. ThreadedHistory was added for this.Changes related to shortcuts.prompt:
There is now a class PromptSession which also has a method prompt. Both
the class and the method take about the same arguments. This can be used to
create a session. Every prompt call of the same instance will reuse all
the arguments given to the class itself.
The input history is always shared during the entire session.
Of course, it's still possible to call the global prompt function. This
will create a new PromptSession every time when it's called.
The prompt function now takes a key_bindings argument instead of
key_bindings_registry. This should only contain the additional bindings.
(The default bindings are always included.)
Changes to the event loops:
The event loop API is now closer to how asyncio works. A prompt_toolkit
Application now has a Future object. Calling the .run_async() method
creates and returns that Future. An event loop has a run_until_complete
method that takes a future and runs the event loop until the Future is set.
The idea is to be able to transition easily to asyncio when Python 2 support can be dropped in the future.
Application still has a method run() that underneath still runs the
event loop until the Future is set and returns that result.
The asyncio adaptors (like the asyncio event loop integration) now require Python 3.5. (We use the async/await syntax internally.)
The Input and Output classes have some changes. (Not really important.)
Application.run_sub_applications has been removed. The alternative is to
call run_coroutine_in_terminal which returns a Future.
Changes to the filters module:
The Application is no longer passed around, so both CLIFilter and
SimpleFilter were merged into Filter. to_cli_filter and
to_simple_filter became to_filter.
All filters have been turned into functions. For instance, IsDone
became is_done and HasCompletions became has_completions.
This was done because almost all classes were called without any arguments
in the __init__ causing additional braces everywhere. This means that
HasCompletions() has to be replaced by has_completions (without
parenthesis).
The few filters that took arguments as input, became functions, but still have to be called with the given arguments.
For new filters, it is recommended to use the @Condition decorator,
rather then inheriting from Filter.
Other renames:
IncrementalSearchDirection was renamed to SearchDirection.use_alternate_screen parameter has been renamed to full_screen.Buffer.initial_document was renamed to Buffer.document.TokenListControl has been renamed to FormattedTextControl.Application.set_return_value has been renamed to Application.set_result.Other new features:
DummyAutoSuggest and DynamicAutoSuggest were added.
DummyClipboard and DynamicClipboard were added.
DummyCompleter and DynamicCompleter were added.
DummyHistory and DynamicHistory was added.
to_container and to_window utilities were added.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Fixed a bug in the cooked_mode context manager. This caused a bug in ptpython where executing input() would display ^M instead of accepting the input.
Fixes:
cooked_mode context manager. This caused a bug in
ptpython where executing input() would display ^M instead of accepting the
input.New features:
In 'shortcuts': complete_while_typing was a SimpleFilter, not a CLIFilter.
Fixes:
New features:
time.time.) This will do less system calls. It's
backwards-incompatible, but this is still a private API, used only by pymux.)Bugfix in completion. When calculating the common completion to be inserted, the new completions were calculated wrong.
Fixes:
New features:
Go to the start of the line in Vi navigation mode, when 'j' or 'k' have been pressed to navigate to a new history entry.
Fixes:
New features:
ansi_colors_only parameter in Vt100_Output and
shortcuts.create_output.Critical fix for running on Windows. The gevent work-around in the inputhook caused 'An operation was attempted on something that is not a socket'.
Fixes:
Improved handling of repeat arguments in Emacs mode. Pressing sequences like 'esc---123' do now work (like GNU Readline):
Fixes:
New features:
For future compatibility:
Keys.Enter has been added. This is the key that should be bound for
handling the enter key.
Right now, prompt_toolkit translates \r into \n during the handling of the
input; this is not correct and makes it impossible to distinguish between
ControlJ and ControlM. Some applications bind ControlJ for custom handling of
the enter key, because this equals \n. However, in a future version we will
stop replacing \r by \n and at that point, the enter key will be ControlM.
So better is to use Keys.Enter, which becomes an alias for whatever the
enter key translates into.
Bugfix for Python2 in readline-like completion.
Fixes:
New features:
erase_when_done parameter to the Application class. (This was
required for the bug fixes.)CommandLineInterface.run_application_generator method.
(Also required for the bug fix.)Don't select the first completion when complete_while_typing is False. (Restore the old behavior.)
Fixes:
complete_while_typing is False.
(Restore the old behavior.)Bugfix in GrammarValidator and SentenceValidator.
Fixes:
New features (**):
Performance improvements:
(**) Some small backwards-compatible features were allowed for this minor release. After evaluating the impact/risk/work involved we concluded that we could ship these in a minor release.
Renamed MouseEventTypes to MouseEventType for consistency. The old name is still valid, but deprecated.
Fixes:
New features:
load_mouse_bindings.complete_while_typing=True or when there are
completions to be displayed.Token.SelectedText to set a fixed foreground/background.
Also for SearchMatch, we now use combined tokens.Backwards-incompatible changes:
reset_current_buffer=True is now
required.PipeInput.send to PipeInput.send_text. (Old deprecated name is
still kept as a valid alias.)ViStateFilter has been deprecated. (Should not
be used anymore.) Use the filters, as defined in prompt_toolkit.filters.editing_mode is now a property of CommandLineInterface. This is replacing
the vi_mode parameter in KeyBindingManager.Don't use deprecated inspect.getargspec on Python 3.
Fixes:
New features:
Set correct default color on Windows. (Gray instead of high intensity gray.)
Fixes:
Correctly return result for mouse handler in TokenListControl.
Fixes:
CommandLineInterface.run(), don't
forget to redraw the CLI.New features:
Many performance improvements and better caching. (Especially in the
Document class.)
Support for continuation tokens in shortcuts.prompt and
shortcuts.create_prompt_layout.
Added shortcuts.print_tokens function for printing colored output.
Sound bell when nothing was deleted.
Added escape sequences for F1-F5 keys on the Linux console.
Improved support for the Linux console. (Switch back to 16 colors.)
Added F13-F24 input codes for xterm.
Created prompt_toolkit.token. A custom Token implementation, that is compatible with Pygments.token. (This way, Pygments becomes an optional dependency. For many use cases, nothing except the Token class from Pygments was used, so it was a bit overkill to install Pygments for only that.)
Refactoring of prompt_toolkit.styles.
Float objects got a hide_when_covering_content option.
Implementation of RPROMPT, like ZSH: Added get_rprompt_tokens to
create_prompt_layout.
Some improvements to the default style.
Also handle Ctrl-R and Ctrl-S in Vi mode when searching.
Added TabsProcessor: a tool to visualize tabs instead of displaying ^I.
Give a better error message when trying to run in git-bash.
Support for ANSI color names in style dictionaries.
Big refactoring of the Window and UIControl classes. This should result
in huge performance improvements on big inputs. (While first, a document
could have 1,000 lines; now it can have about 100,000 lines on the same system.)
The Window and UIControl have been rewritten very much. Rather than each time rendering the whole user control, we now only have to render the visible part.
Because of this, many pieces had to be rewritten:
UIContent instance that
consist of a collection of lines.Lexer.lex_document should now return a function
that returns the tokens for one line. PygmentsLexer has been optimized that
it becomes 'lazy', and it has optional syntax synchronization. That means,
that the lexer doesn't have to start the lexing at the beginning of the
document. (Which would be slow for big documents.)Backwards-incompatible changes:
Window and UIControl caused many
"internal" APIs to change. All custom UIControl, Processor and Lexer
classes have to be rewritten. However, for most applications this should not
be an issue. Especially, the shortcuts.prompt function is
backwards-compatible.wrap_lines became a property of Window instead of BufferControl.Made max_render_postpone_time configurable. The current default was bad. (We should probably always draw the UI once every cycle of the event loop.)
Fixes:
max_render_postpone_time configurable. The current default was bad.
(We should probably always draw the UI once every cycle of the event loop.)Fix in bracketed paste. It was not correctly enabled for each prompt.
Fixes:
HighlightSearchProcessor and HighlightSelectionProcessor became deprecated. (Use highlighters instead.)
New features:
Fixes:
Backwards-incompatible changes: (Most changes will probably not have an impact on external applications.)
Style API. This allows caching of Attrs in renderer and
faster rendering. (Style now has a get_attrs_for_token instead of a
get_token_to_attributes_dict method.)Allow CommandLineInterface to run in any thread.
New features:
Fixes:
Backwards-incompatible changes:
Handling of the insert key in Vi mode.
New features:
wrap_lines option to TokenListControl.KeyBindingManager.for_prompt.Fixes:
AbortAction.RETRY.CompleteEvent. Correctly set completion_requested.Backwards-incompatible changes:
ValidationError.index to ValidationError.cursor_position.shortcuts.get_input to shortcuts.prompt.Document.current_char/char_before_cursor.Fix in auto suggestion: hide suggestion when accepting input.
Fixes:
Mouse support. (Scrolling and clicking for vt100 terminals. For Windows only clicking.) Both the autocompletion menus and buffer controls respond to s
New features:
Fixes:
Backwards-incompatible changes:
Application.Buffer.SwitchableValidator has been renamed to ConditionalValidator.WindowRenderInfo has several incompatible changes.BufferControl. Is is both much more performant and
flexible.Leaving of alternate screen on Windows.
Fix:
Removed deprecated 'tokens' attribute from GrammarLexer.
New features:
shortcuts.create_default_application.align_center option for TokenListControl.Fixes:
Backwards-incompatible changes:
run_in_terminal now returns the result of the called function.
New features:
Fixes:
Added prompt_toolkit.layout.utils.iter_token_lines.
New features:
prompt_toolkit.layout.utils.iter_token_lines.None values on the focus stack.IsReadOnly filter.eager behavior for key bindings. When a key binding is eager it will be
executed as soon as it's matched, even when there is another binding that
starts with this key sequence.Fixes:
pre_run parameter to CommandLineInterface.Backwards-incompatible changes:
Lexer abstract base class. Every lexer should be an instance
of that class, and Pygments lexers should be wrapped in a PygmentsLexer
class. prompt_toolkit.shortcuts still accepts Pygments lexers directly for
backwards-compatibility.show_line_numbers argument. Pass a
NumberedMargin instance instead.History class became an abstract base class and only defines an
interface. The default history class is now called InMemoryHistory.By default, in shortcuts, only show search highlighting when the search is the current input buffer.
New features:
shortcuts.create_default_layout accepts a multiline parameter.Fixes:
Backwards-incompatible changes:
ConditionalContainer everywhere. The Window class no longer
accepts a filter argument to decide about the visibility. Instead
wrapping inside a ConditionalContainer class is required.Bug fix on OS X: correctly detect platform as not Windows.
Fixes:
Fixed bug in eventloops: handle timeout correctly, even when there is an eventhook.
Fixes:
New features:
Backwards incompatible changes:
Fixes:
New features:
Backwards incompatible changes:
Support for Windows cmder and conemu consoles.
Fixes:
New features:
Color fix for Windows consoles.
Fixes:
New features:
password can be a Filter now.Backwards incompatible changes:
Fixes:
New features:
Backwards incompatible changes:
Fixed eventloop for Python 64bit on Windows.
Fixes:
Backwards incompatible changes:
New features:
Bug fixes:
Backwards incompatible changes:
Handling of trailing input in contrib.regular_languages.
New features:
Bug fixes:
Added get_prompt_tokens parameter to create_default_layout.
New features:
Bug fixes:
Backwards incompatible changes:
New features:
Bug fixes:
Backwards incompatible changes:
Backwards incompatible changes:
Bug fixes:
Backwards incompatible changes:
Backwards incompatible changes:
Bug fixes:
New features:
Backwards incompatible changes:
Backwards incompatible changes:
New features:
Fixed:
Changes:
Backwards incompatible changes:
Show completion menu only for the default_buffer in get_input.
Fixed:
New features:
Backward compatibility with django_extensions.
Fixed:
New features:
Fixed: - syntax error in 0.27
Fixed:
Backwards-incompatible changes:
Backwards-incompatible changes:
Line to Buffer.New features:
Fixed:
Package did not install on Python 2.6/2.7.
Fixed:
Improved j/k key bindings in Vi mode.
New features:
Fixed:
Fixed missing import which caused Ctrl-Z to crash.
Fixed:
Experimental Win32 support added.
New features:
Fixed:
Better handling of window resize events.
Fixed:
New features:
Execution of system commands (in ptpython) in Python 3
Fixed:
ptipythonptipythonptpython) in Python 3ptpython.New features
ptpython can now also run python scripts, so aliasing of ptpython as
python will work better.Your coding agent can read these notes before it upgrades. Set up the MCP server →