Editor

Editor

class kable.editor.Editor(initial_text='', **kwargs)[source]

Bases: TextArea

The editor widget for Kable. :param initial_text: The text to be displayed in the TextArea. :example: Editor (initial_text = ‘hello’)

Parameters:

initial_text (str)

__init__(initial_text='', **kwargs)[source]

The __init__ function for this widget. :param initial_text: The text to be displayed in the TextArea.

Parameters:

initial_text (str)

Return type:

None

save_file(file_path)[source]

Saves the contents of the editor to the specified file. :param file_path: The path of the file to save to. :raises Exception: Upon a file write error.

Parameters:

file_path (Path)

Return type:

None

load_file(file_path)[source]

Loads a file into the editor. :param file_path: The path of the file to load. :raises Exception: Upon file read error.

Parameters:

file_path (Path)

Return type:

None

update_location_label(location_label)[source]

Updates the location of the cursor in the editor. :param location_label: The Label to update.

Parameters:

location_label (Label)

Return type:

None

has_unsaved_changes(file_path)[source]

Check whether the editor contents differ from the file on disk.

Parameters:

file_path (Path) – The path of the file to compare against.

Returns:

True if the editor contains unsaved changes, otherwise False.

Return type:

bool

get_text()[source]

Get the current editor contents.

Returns:

The text currently contained in the editor.

Return type:

str

set_text(text)[source]

Set the editor contents.

Parameters:

text (str) – The text to place in the editor.

Return type:

None