euporie.console.tabs.console

Contain the main class for a notebook file.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

add_setting(name, default, help_, description)

Register a new config item.

cast(typ, val)

Cast a value to a type.

edit_in_editor(filename[, line_number])

Suspend the current app and edit a file in an external editor.

format_code(text, config)

Format a code string using :py:mod:``.

get_cmd(name)

Get a command from the centralized command system by name.

has_focus(value)

Enable when this buffer has the focus.

in_terminal([render_cli_done])

Asynchronous context manager that suspends the current application and runs the body in the terminal.

load_registered_bindings(*names[, config])

Assign key-bindings to commands based on a dictionary.

register_bindings(bindings)

Update the key-binding registry.

Classes

Buffer([completer, auto_suggest, history, ...])

The core data structure that holds the text and cursor position of the current input line and implements all text manipulations on top of it.

CellOutputArea(json, parent[, style])

An area below a cell where one or more cell outputs can be shown.

Condition(func)

Turn any callable into a Filter.

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.

Console(app[, path, use_kernel_history, ...])

Interactive console.

FloatContainer(content, floats[, modal, ...])

Container which can contain another container for the background, as well as a list of floating containers on top of it.

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

Control that displays formatted text.

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

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

KernelInput(kernel_tab, *args[, ...])

Kernel input text areas.

KernelTab(app[, path, kernel, comms, ...])

A Tab which connects to a kernel.

KernelValidator(kernel)

Validate kernel input using a kernel code completeness call.

KeyBindings()

A container for a set of key bindings.

Layout(container[, focused_element])

The layout for a prompt_toolkit Application.

MsgCallbacks

Typed dictionary for named message callbacks.

PagerState(code, cursor_pos, response)

A named tuple which describes the state of a pager.

PrintingContainer(children[, width, ...])

A container which displays all it's children in a vertical list.

StdInput(kernel_tab)

A widget to accept kernel input.

UPath(*args, **kwargs)

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

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

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

The validation state of a buffer.

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.console.tabs.console.Console(app: BaseApp, path: Path | None = None, use_kernel_history: bool = True, connection_file: str = '')

Bases: euporie.core.tabs.base.KernelTab

Interactive console.

An interactive console which connects to a Jupyter kernel.

accept_stdin(buf: prompt_toolkit.buffer.Buffer) bool

Accept the user’s input.

allow_stdin: bool
async async_render_outputs() None

Render any unrendered outputs above the application.

bg_init = False
change_kernel(msg: str | None = None, startup: bool = False) None

Prompt the user to select a new kernel.

clear_output(wait: bool = False) None

Remove the last output, optionally when new output is generated.

close(cb: Callable | None = None) None

Close the console tab.

comm_close(content: dict, buffers: Sequence[bytes]) None

Close a notebook Comm.

comm_msg(content: dict, buffers: Sequence[bytes]) None

Respond to a Comm message from the kernel.

comm_open(content: dict, buffers: Sequence[bytes]) None

Register a new kernel Comm object in the notebook.

complete(content: dict | None = None) None

Re-render any changes.

container: AnyContainer
default_callbacks: MsgCallbacks
file_extensions: set[str] = {}
focus() None

Focus the tab (or make it visible).

init_kernel(kernel: Kernel | None = None, comms: dict[str, Comm] | None = None, use_kernel_history: bool = False, connection_file: Path | None = None) None

Set up the tab’s kernel and related components.

inspect() None

Get contextual help for the current cursor position in the current cell.

interrupt_kernel() None

Interrupt the current Notebook’s kernel.

kernel: Kernel
kernel_died() None

Call when the kernel dies.

property kernel_display_name: str

Return the display name of the kernel defined in the notebook JSON.

property kernel_lang_file_ext: str

Return the display name of the kernel defined in the notebook JSON.

kernel_language: str
property kernel_name: str

Return the name of the kernel defined in the notebook JSON.

kernel_started(result: dict[str, Any] | None = None) None

Task to run when the kernel has started.

lang_file_ext() str

Return the file extension for scripts in the notebook’s language.

property language: str

The language of the current kernel.

load_container() prompt_toolkit.layout.containers.HSplit

Build the main application layout.

async load_history() None

Load kernel history.

property metadata: dict[str, Any]

Return a dictionary to hold notebook / kernel metadata.

mime_types: set[str] = {}
name: str | None = None
new_output(output_json: dict[str, Any]) None

Print the previous output and replace it with the new one.

post_init_kernel() None

Run stuff after the kernel is loaded.

pre_init_kernel() None

Run stuff before the kernel is loaded.

prompt(text: str, offset: int = 0, show_busy: bool = False) StyleAndTextTuples

Determine what should be displayed in the prompt of the cell.

reformat() None

Reformat the input.

refresh(now: bool = True) None

Request the output is refreshed (does nothing).

render_outputs(app: Application[Any]) None

Request that any unrendered outputs be rendered.

report_kernel_error(error: Exception | None) None

Report a kernel error to the user.

reset() None

Reet the state of the tab.

restart_kernel(cb: Callable | None = None) None

Restart the current Notebook’s kernel.

run(buffer: prompt_toolkit.buffer.Buffer | None = None) None

Run the code in the input box.

save(path: Path | None = None, cb: Callable | None = None) None

Save the console as a notebook.

set_kernel_info(info: dict) None

Receive and processes kernel metadata.

set_next_input(text: str, replace: bool = False) None

Set the text for the next prompt.

property title: str

Return the tab title.

validate_input(code: str) bool

Determine if the entered code is ready to run.

weight: int = 0