euporie.core.widgets.layout

Define widget for defining layouts.

Functions

NamedTuple(typename[, fields])

Typed version of namedtuple.

abstractmethod(funcobj)

A decorator indicating abstract methods.

cast(typ, val)

Cast a value to a type.

fragment_list_width(fragments)

Return the character width of this text fragment list.

get_app()

Get the current active (running) Application.

to_container(container)

Make sure that the given object is a Container.

to_filter(bool_or_filter)

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.

truncate(ft, width[, style, placeholder, ...])

Truncate all lines at a given length.

Classes

ABCMeta(name, bases, namespace, /, **kwargs)

Metaclass for defining Abstract Base Classes (ABCs).

AccordionSplit(children, titles[, active, ...])

A container which switches between children using expandable sections.

Border(body, border, style, str] =, show_borders)

Draw a border around any container.

Box(body[, padding, padding_left, ...])

Add padding around a container.

Condition(func)

Turn any callable into a Filter.

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.

ConditionalSplit(vertical, *args, **kwargs)

A split container where the orientation depends on a filter.

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

A tuple of four bools with directions.

DynamicContainer(get_container)

Container class that dynamically returns any Container.

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

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

Control that displays formatted text.

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

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

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

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

ReferencedSplit(split, children, *args, **kwargs)

A split container which maintains a reference to it's children.

SimpleCache([maxsize])

Very simple cache that discards the oldest item when the cache size is exceeded.

StackedSplit(children, titles[, active, ...])

Base class for containers with selectable children.

TabBarControl(tabs, active[, spacing, ...])

A control which shows a tab bar.

TabBarTab(title, on_activate[, ...])

A named tuple represting a tab and it's callbacks.

TabbedSplit(children, titles, active, style, ...)

A container which switches between children using tabs.

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

Content generated by a user control.

UIControl()

Base class for all user interface controls.

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

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

class euporie.core.widgets.layout.AccordionSplit(children: Sequence[AnyContainer], titles: Sequence[AnyFormattedText], active: int = 0, style: str | Callable[[], str] = 'class:tab-split', on_change: Callable[[StackedSplit], None] | None = None, width: AnyDimension = None, height: AnyDimension = None)

Bases: euporie.core.widgets.layout.StackedSplit

A container which switches between children using expandable sections.

property active: int | None

Return the index of the active child container.

active_child() AnyContainer

Return the currently active child container.

add_style(style: str) str

Add a style to the widget’s base style.

property children: list[AnyContainer]

Return a list of the widget’s child containers.

draw_container() None

Render the accordion in it’s current state.

load_container() AnyContainer

Create the accordiion widget’s container.

mouse_handler(index: int, mouse_event: MouseEvent) NotImplementedOrNone

Handle mouse events.

refresh() None

Re-draw the container when the list of child containers changes.

title_text(index: int, title: AnyFormattedText) StyleAndTextTuples

Generate the title for each child container.

property titles: list[AnyFormattedText]

Return the titles of the child containers.

toggle(index: int) None

Toggle the visibility of a child container.

class euporie.core.widgets.layout.ConditionalSplit(vertical: FilterOrBool, *args: Any, **kwargs: Any)

Bases: object

A split container where the orientation depends on a filter.

container() _Split

Return the container for the current orientation.

load_container(vertical: bool) _Split

Load the container.

class euporie.core.widgets.layout.ReferencedSplit(split: type[_Split], children: Sequence[AnyContainer], *args: Any, **kwargs: Any)

Bases: object

A split container which maintains a reference to it’s children.

property children: list[AnyContainer]

Convert the referenced children to containers.

class euporie.core.widgets.layout.StackedSplit(children: Sequence[AnyContainer], titles: Sequence[AnyFormattedText], active: int = 0, style: str | Callable[[], str] = 'class:tab-split', on_change: Callable[[StackedSplit], None] | None = None, width: AnyDimension = None, height: AnyDimension = None)

Bases: object

Base class for containers with selectable children.

property active: int | None

Return the index of the active child container.

active_child() AnyContainer

Return the currently active child container.

add_style(style: str) str

Add a style to the widget’s base style.

property children: list[AnyContainer]

Return a list of the widget’s child containers.

abstract load_container() AnyContainer

Abstract method for loading the widget’s container.

refresh() None

Reload the widget’s container when its children or their titles change.

property titles: list[AnyFormattedText]

Return the titles of the child containers.

class euporie.core.widgets.layout.TabBarControl(tabs: Sequence[TabBarTab] | Callable[[], Sequence[TabBarTab]], active: int | Callable[[], int], spacing: int = 1, closeable: bool = False, max_title_width: int = 30)

Bases: prompt_toolkit.layout.controls.UIControl

A control which shows a tab bar.

property active: int

Return the index of the active tab.

char_bottom = '▁'
char_close = '✖'
char_left = '▏'
char_right = '▕'
char_top = '▁'
create_content(width: int, height: int) prompt_toolkit.layout.controls.UIContent

Generate the formatted text fragments which make the controls output.

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.

is_focusable() bool

Tell whether this user control is focusable.

mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone

Handle mouse events.

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

Return the preferred height of the tab-bar control (2 rows).

preferred_width(max_available_width: int) int | None

Return the preferred width of the tab-bar control, the maximum available.

render(width: int) list[StyleAndTextTuples]

Render the tab-bar as linest of formatted text.

reset() None
property tabs: list[euporie.core.widgets.layout.TabBarTab]

Return the tab-bar’s tabs.

class euporie.core.widgets.layout.TabBarTab(title: AnyFormattedText, on_activate: Callable, on_deactivate: Callable | None = None, on_close: Callable | None = None)

Bases: NamedTuple

A named tuple represting a tab and it’s callbacks.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

on_activate: Callable

Alias for field number 1

on_close: Callable | None

Alias for field number 3

on_deactivate: Callable | None

Alias for field number 2

title: AnyFormattedText

Alias for field number 0

class euporie.core.widgets.layout.TabbedSplit(children: Sequence[AnyContainer], titles: Sequence[AnyFormattedText], active: int = 0, style: str | Callable[[], str] = 'class:tab-split', on_change: Callable[[StackedSplit], None] | None = None, width: AnyDimension = None, height: AnyDimension = None, border: GridStyle = ▁▁▁▁ │▕ ▏─┼▕ ▔▔▔▔, show_borders: DiBool | None = None)

Bases: euporie.core.widgets.layout.StackedSplit

A container which switches between children using tabs.

property active: int | None

Return the index of the active child container.

active_child() AnyContainer

Return the currently active child container.

add_style(style: str) str

Add a style to the widget’s base style.

property children: list[AnyContainer]

Return a list of the widget’s child containers.

load_container() AnyContainer

Create the tabbed widget’s container.

Consists of a tab-bar control above a dynamic container which shows the active child container.

Returns

The widget’s container

load_tabs() list[euporie.core.widgets.layout.TabBarTab]

Return a list of tabs for the current children.

refresh() None

Refresh the widget - set the tab-bar’s tabs and active tab index.

property titles: list[AnyFormattedText]

Return the titles of the child containers.