Define an application menu.



Turn a list of (style_str, text) tuples into another list where each string is exactly one character.


Concatenate all the text parts again.


Return the character width of this text fragment list.


Get the current active (running) Application.


Return width of a string.


Accept both booleans and Filters as input and turn it into a Filter.

to_formatted_text(value[, style, auto_convert])

Convert the given value (which can be formatted text) into a list of text fragments.


Turn any kind of formatted text back into plain text.


CompletionsMenu([max_height, scroll_offset, ...])

A custom completions menu.


A custom completions menu control.


Turn any callable into a Filter.

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.


Base class for user interface layout.

Dimension([min, max, weight, preferred])

Specified dimension (width/height) of a user control or window.

Float(content[, top, right, bottom, left, ...])

Float for use in a FloatContainer.

FormattedTextControl([text, style, ...])

Control that displays formatted text.

HSplit(children[, window_too_small, align, ...])

Several layouts, one stacked above/under the other. ::.


A container for a set of key bindings.

MenuBar(app, menu_items, grid)

A container to hold the menubar and main application body.

MenuItem([formatted_text, description, ...])

A prompt-toolkit compatible menu item with more advanced capabilities.

MouseEvent(position, event_type, button, ...)

Mouse event, sent to UIControl.mouse_handler.

MouseEventType(value[, names, module, ...])

Point(x, y)


alias of prompt_toolkit.layout.menus.CompletionsMenuControl

ScrollOffsets([top, bottom, left, right])

Scroll offsets for the Window class.


Draw a shadow underneath/behind this container.

UIContent(get_line, StyleAndTextTuples] = >, ...)

Content generated by a user control.

VSplit(children[, window_too_small, align, ...])

Several layouts, one stacked left/right of the other. ::.

Window([content, width, height, z_index, ...])

Container that holds a control.


partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

class int | None = 16, scroll_offset: int | Callable[[], int] = 1, extra_filter: FilterOrBool = True, z_index: int = 100000000)

Bases: prompt_toolkit.layout.containers.ConditionalContainer

A custom completions menu.

get_children() list[prompt_toolkit.layout.containers.Container]

Return the list of child Container objects.

get_key_bindings() prompt_toolkit.key_binding.key_bindings.KeyBindingsBase | None

Returns a KeyBindings object. These bindings become active when any user control in this container has the focus, except if any containers between this container and the focused user control is modal.

is_modal() bool

When this container is modal, key bindings from parent containers are not taken into account if a user control in this container is focused.

preferred_height(width: int, max_available_height: int) prompt_toolkit.layout.dimension.Dimension

Return a Dimension that represents the desired height for this container.

preferred_width(max_available_width: int) prompt_toolkit.layout.dimension.Dimension

Return a Dimension that represents the desired width for this container.

reset() None

Reset the state of this container and all the children. (E.g. reset scroll offsets, etc…)

write_to_screen(screen: prompt_toolkit.layout.screen.Screen, mouse_handlers: prompt_toolkit.layout.mouse_handlers.MouseHandlers, write_position: prompt_toolkit.layout.screen.WritePosition, parent_style: str, erase_bg: bool, z_index: int | None) None

Write the actual content to the screen.

  • screenScreen

  • mouse_handlersMouseHandlers.

  • parent_style – Style string to pass to the Window object. This will be applied to all content of the windows. VSplit and HSplit can use it to pass their style down to the windows that they contain.

  • z_index – Used for propagating z_index from parent to child.


Bases: prompt_toolkit.layout.menus.CompletionsMenuControl

A custom completions menu control.

create_content(width: int, height: int) prompt_toolkit.layout.controls.UIContent

Create a UIContent object for this control.

get_invalidate_events() Iterable[Event[object]]

Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)

get_key_bindings() KeyBindingsBase | None

The key bindings that are specific for this user control.

Return a KeyBindings object if some key bindings are specified, or None otherwise.

has_focus() bool
is_focusable() bool

Tell whether this user control is focusable.

mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone

Handle mouse events: clicking and scrolling.

move_cursor_down() None

Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.

move_cursor_up() None

Request to move the cursor up.

preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None
preferred_width(max_available_width: int) int | None
reset() None
class BaseApp, menu_items: Sequence[MenuItem], grid: GridStyle = ▛▀▀▜ │▐ ▌─┼▐ ▙▄▄▟)

Bases: object

A container to hold the menubar and main application body.

class AnyFormattedText = '', description: str = '', separator: bool = False, handler: Callable[[], None] | None = None, children: list[MenuItem] | None = None, shortcut: AnyFormattedText = '', hidden: FilterOrBool = False, disabled: FilterOrBool = False, toggled: Filter | None = None, collapse_prefix: bool = False, collapse_suffix: bool = True)

Bases: object

A prompt-toolkit compatible menu item with more advanced capabilities.

It can use a function to generate formatted text to display, display a checkmark if a condition is true, and disable the handler if a condition is met.

property disabled: bool

Determine if the menu item is disabled.

property formatted_text: StyleAndTextTuples

Generate the formatted text for this menu item.

classmethod from_command(command: Command) MenuItem

Create a menu item from a command.

property has_toggles: bool

Return true if any child items have a toggle state.

property prefix: StyleAndTextTuples

The item’s prefix.

Formatted text that will be displayed before the item’s main text. All prefixes in a menu are left aligned and padded to take up equal width.


Formatted text

property prefix_width: int

The maximum width of the item’s children’s prefixes.

property suffix: StyleAndTextTuples

The item’s suffix.

Formatted text that will be displayed aligned right after them item’s main text.


Formatted text

property suffix_width: int

The maximum width of the item’s children’s suffixes.

property text: str

Return plain text verision of the item’s formatted text.

property width: int

The maximum width of the item’s children.