spinetoolbox.widgets.persistent_console_widget

Contains a widget acting as a console for Julia & Python REPL’s.

Module Contents

Classes

_CustomLineEdit

PersistentConsoleWidget

A widget to interact with a persistent process.

AnsiEscapeCodeHandler

Functions

_ansi_color(code[, bright])

class spinetoolbox.widgets.persistent_console_widget._CustomLineEdit(console)[source]

Bases: PySide6.QtWidgets.QPlainTextEdit

property min_pos[source]
property new_line_indent[source]
reset(current_prompt)[source]
new_line()[source]
formatted_text()[source]
raw_text()[source]
set_raw_text(text)[source]
_handle_text_changed()[source]

Add indent to new lines.

_handle_cursor_position_changed()[source]

Move cursor away from indent areas.

keyPressEvent(ev)[source]
class spinetoolbox.widgets.persistent_console_widget.PersistentConsoleWidget(toolbox, key, language, owner=None)[source]

Bases: PySide6.QtWidgets.QPlainTextEdit

A widget to interact with a persistent process.

Parameters
  • toolbox (ToolboxUI) –

  • key (tuple) – persistent process identifier

  • language (str) – for syntax highlighting and prompting, etc.

  • owner (ProjectItemBase, optional) – console owner

property prompt[source]
property owner_names[source]
property _input_start_pos[source]
_command_checked[source]
_msg_available[source]
_command_finished[source]
_history_item_available[source]
_completions_available[source]
_restarted[source]
_killed[source]
_flush_needed[source]
_FLUSH_INTERVAL = 200[source]
_MAX_LINES_PER_SECOND = 2000[source]
_MAX_LINES_PER_CYCLE[source]
_MAX_LINES_COUNT = 2000[source]
closeEvent(ev)[source]
name()[source]

Returns console name for display purposes.

focusInEvent(ev)[source]
mouseMoveEvent(ev)[source]
mousePressEvent(ev)[source]
mouseReleaseEvent(ev)[source]
scrollContentsBy(dx, dy)[source]
_handle_contents_changed()[source]
_handle_selection_changed()[source]
_handle_cursor_position_changed()[source]
_handle_update_request(_rect, _dy)[source]

Move line edit to input start pos.

resizeEvent(ev)[source]
_move_and_resize_line_edit()[source]
_update_user_input()[source]
_start_flush_timer()[source]
_flush_text_buffer()[source]

Inserts all text from buffer.

_make_prompt()[source]
_make_prompt_block(prompt='')[source]
_insert_prompt(prompt='')[source]
_insert_stdin_text(cursor, text)[source]

Inserts highlighted text.

Parameters
  • cursor (QTextCursor) –

  • text (str) –

_do_insert_stdin_text(cursor, text)[source]
_insert_stdout_text(cursor, text)[source]

Inserts ansi highlighted text.

Parameters
  • cursor (QTextCursor) –

  • text (str) –

_insert_text_before_prompt(text, with_prompt=False)[source]

Inserts given text before the prompt. Used when adding input and output from external execution.

Parameters

text (str) –

_insert_text(cursor, text, with_prompt)[source]
set_killed(killed)[source]

Emits the killed signal.

Parameters

killed (bool) – if True, may the console rest in peace

_do_set_killed(killed)[source]

Sets the console as killed or alive.

Parameters

killed (bool) – if True, may the console rest in peace

add_stdin(data)[source]

Adds new prompt with data. Used when adding stdin from external execution.

Parameters

data (str) –

add_stdout(data)[source]

Adds new line to stdout. Used when adding stdout from external execution.

Parameters

data (str) –

add_stderr(data)[source]

Adds new line to stderr. Used when adding stderr from external execution.

Parameters

data (str) –

_get_current_text()[source]
_get_prefix()[source]
_highlight_current_input()[source]
key_press_event(ev)[source]

Handles key press event from line edit.

Returns

True if handled, False if not.

create_engine_manager()[source]

Returns a new local or remote spine engine manager or an existing remote spine engine manager. Returns None if connecting to Spine Engine Server fails.

_issue_command(text)[source]

Issues command.

Parameters

text (str) –

_do_check_command(text)[source]
_handle_command_checked(text, complete)[source]

Issues command.

Parameters

text (str) –

_do_issue_command(text)[source]
_handle_msg_available(msg_type, text)[source]
_handle_command_finished()[source]
_move_history(text, backwards)[source]

Moves history.

_do_move_history(text, backwards)[source]
_display_history_item(history_item, prefix)[source]
_autocomplete(text)[source]

Autocompletes current text in the prompt (or output options if multiple matches).

Parameters

text (str) –

_do_autocomplete(text)[source]
_display_completions(text, prefix, completions)[source]
_restart_persistent(_=False)[source]

Restarts underlying persistent process.

_do_restart_persistent()[source]
_handle_restarted()[source]
_interrupt_persistent(_=False)[source]

Sends a task to executor which will interrupt the underlying persistent process.

_do_interrupt_persistent()[source]

Interrupts the underlying persistent process.

_kill_persistent(_=False)[source]

Sends a task to executor which will kill the underlying persistent process.

_do_kill_persistent()[source]

Kills underlying persistent process.

_extend_menu(menu)[source]

Appends two more actions: Restart, and Interrupt.

Parameters

menu (QMenu) – where to append

contextMenuEvent(ev)[source]

Reimplemented to extend menu with custom actions.

class spinetoolbox.widgets.persistent_console_widget.AnsiEscapeCodeHandler(fg_color, bg_color)[source]
_make_default_format()[source]
endFormatScope()[source]
setFormatScope(char_format)[source]
parse_text(text)[source]
spinetoolbox.widgets.persistent_console_widget._ansi_color(code, bright=False)[source]