euporie.notebook.tabs.notebook
Contain the main class for a notebook file.
Functions
|
Add a command to the centralized command system. |
|
Register a new config item. |
|
Cast a value to a type. |
|
Deep copy operation on arbitrary Python objects. |
|
Get the current active (running) Application. |
|
Get a command from the centralized command system by name. |
|
Assign key-bindings to commands based on a dictionary. |
|
Update the key-binding registry. |
Classes
|
The main notebook container class. |
|
A kernel_tab cell element. |
|
Text on the clipboard. |
|
Turn any callable into a Filter. |
|
Wrapper around any other container that can change the visibility. |
|
Specified dimension (width/height) of a user control or window. |
|
A Tab which connects to a kernel. |
|
Draw a horizontal or vertical line. |
|
A container which renders a stand-alone margin. |
|
|
|
Interactive notebooks. |
|
Fill an area with a repeating background pattern. |
|
Margin displaying a scrollbar. |
|
A scrollable container which renders only the currently visible children. |
|
Several layouts, one stacked left/right of the other. ::. |
deque([iterable[, maxlen]]) --> deque object |
|
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
- class euporie.notebook.tabs.notebook.Notebook(app: BaseApp, path: Path | None = None, kernel: Kernel | None = None, comms: dict[str, Comm] | None = None, use_kernel_history: bool = True, json: dict[str, Any] | None = None)
Bases:
euporie.core.tabs.notebook.BaseNotebook
Interactive notebooks.
A tab which allows running and editing a notebook.
- add(index: int, source: str = '', **kwargs: Any) None
Create a new cell at a given index.
- Parameters
index – The position at which to insert a new cell
source – The contents of the new cell
kwargs – Additional parameters for the cell
- bg_init = True
- property cell: euporie.core.widgets.cell.Cell
Return the currently selected Cell in this Notebook.
- change_kernel(msg: str | None = None, startup: bool = False) None
Prompt the user to select a new kernel.
- close(cb: Callable | None = None) None
Check if the user want to save an unsaved notebook, then close the file.
- Parameters
cb – A callback to run if after closing the notebook.
- comm_open(content: dict, buffers: Sequence[bytes]) None
Register a new kernel Comm object in the notebook.
- container: AnyContainer
- copy(slice_: slice | None = None) None
Add a copy of the selected cells to the Notebook’s clipboard.
- cut(slice_: slice | None = None) None
Remove cells from the notebook and them to the Notebook’s clipboard.
- default_callbacks: MsgCallbacks
- edit_mode = False
- get_cell_by_id(cell_id: str) euporie.core.widgets.cell.Cell | None
Return a reference to the Cell container with a given cell id.
- 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.
- 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.
- load_container() AnyContainer
Load the main notebook container.
- mode() str
Return a symbol representing the current mode.
^
: Notebook mode>
: Navigation modeI
: Insert modev
: Visual mode
- Returns
A character representing the current mode
- move(n: int, slice_: slice | None = None) None
Move a slice of cells up or down.
- Parameters
slice – A slice describing the cell indices to move
n – The amount to move them by
- paste(index: int | None = None) None
Append the contents of the Notebook’s clipboard below the current cell.
- refresh(slice_: slice | None = None, scroll: bool = True) None
Refresh the rendered contents of this notebook.
- refresh_cell(cell: euporie.core.widgets.cell.Cell) None
Trigger the refresh of a notebook cell.
- rendered_cells() list[euporie.core.widgets.cell.Cell]
Return a list of rendered notebooks’ cells.
- run_cell(cell: Cell, wait: bool = False, callback: Callable[..., None] | None = None) None
Run a cell.
- Parameters
cell – The rendered cell to run. If
None
, runs the currently selected cell.wait – If
True
, blocks until cell execution is finishedcallback – Function to run after completion
- run_selected_cells(advance: bool = False, insert: bool = False) None
Run the currently selected cells.
- Parameters
advance – If True, move to next cell. If True and at the last cell, create a new cell at the end of the notebook.
insert – If True, add a new empty cell below the current cell and select it.
- save(path: Path | None = None, cb: Callable | None = None) None
Write the notebook’s JSON to the current notebook’s file.
Additionally save the widget state to the notebook metadata.
- Parameters
path – An optional new path at which to save the tab
cb – A callback to run if after saving the notebook.
- select(index: int, extend: bool = False, position: int | None = None, scroll: bool = True) None
Select a cell or adds it to the selection.
- Parameters
index – The index of the cell to select
extend – If true, the selection will be extended to include the cell
position – An optional cursor position index to apply to the cell input
scroll – Whether to scroll the page