spyder.api.shellconnect.main_widget#

Main widget for plugins showing content from the IPython Console.

Used in, for example, the Variable Explorer, Plots, Debugger and Profiler plugins.

Classes

ShellConnectMainWidget(*args[, set_layout])

Main widget to use in a plugin that shows different content per-console.

class spyder.api.shellconnect.main_widget.ShellConnectMainWidget(*args: Any, set_layout: bool = True, **kwargs: Any)[source]#

Bases: PluginMainWidget

Main widget to use in a plugin that shows different content per-console.

It is composed of a QStackedWidget to stack the widget associated to each console shell widget, and only show one of them at a time. The current widget in the stack displays the content corresponding to the console with focus.

Used in the Variable Explorer and Plots plugins, for example, to show the variables and plots of the current console.

__init__(*args: Any, set_layout: bool = True, **kwargs: Any) None[source]#

Create a new main widget to show console-specific content.

Parameters:
Return type:

None

current_widget() QWidget[source]#

Get the currently displayed widget (either the stack or error widget).

Returns:

The currently displayed widget, either the active widget in the stack associated with the current ShellWidget (i.e. IPython Console tab), or if that kernel failed with an error, the error message widget.

Return type:

QWidget

get_focus_widget() QWidget[source]#

Get the stack widget associated to the currently active shell widget.

Used by change_visibility() when switching to the plugin.

Returns:

The current widget in the stack, associated with the active ShellWidget (i.e. IPython Console tab), to give focus to.

Return type:

QWidget

update_style() None[source]#

Update the stylesheet and style of the stack widget.

Caution

If overriding this method, super must be called for this widget to display correctly in the Spyder UI.

Return type:

None

count() int[source]#

Get the number of widgets in the stack.

Returns:

The number of widgets in the stack.

Return type:

int

get_widget_for_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) QWidget | None[source]#

Retrieve the stacked widget corresponding to the given shell widget.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget to return the associated widget of.

Returns:

The widget in the stack associated with shellwidget, or None if not found.

Return type:

QWidget | None

add_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) None[source]#

Create a new widget in the stack associated to a given shell widget.

This method registers a new widget to display the content that is associated with the given shell widget.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget to associate the new widget to.

Return type:

None

remove_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) None[source]#

Remove the stacked widget associated to a given shell widget.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget to remove the associated widget of.

Return type:

None

set_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) None[source]#

Set as active the stack widget associated with the given shell widget.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget that corresponds to the stacked widget to set as currently active.

Return type:

None

add_errored_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) None[source]#

Add an error widget for a shell widget whose kernel failed to start.

This is necessary to show a meaningful message when switching to consoles with dead kernels.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget to associate with a new error widget.

Return type:

None

create_new_widget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) QWidget[source]#

Create a new widget to communicate with the given shell widget.

Parameters:

shellwidget (spyder.plugins.ipythonconsole.widgets.ShellWidget) – The shell widget to create a new associated widget for.

Returns:

The newly-created widget associated with shellwidget.

Return type:

QWidget

close_widget(widget: QWidget) None[source]#

Close the given stacked widget.

Parameters:

widget (QWidget) – The widget to close.

Return type:

None

switch_widget(widget: QWidget, old_widget: QWidget) None[source]#

Switch the given stacked widget.

Parameters:
  • widget (QWidget) – The widget to switch to.

  • old_widget (QWidget) – The previously-active widget.

Return type:

None

refresh() None[source]#

Refresh the current stacked widget.

Return type:

None

is_current_widget_error_message() bool[source]#

Check if the current widget is showing an error message.

Returns:

True if the current widget is showing an error message, False if not.

Return type:

bool

switch_empty_message(value: bool) None[source]#

Switch between the empty message widget or the one with content.

Parameters:

value (bool) – If True, switch to the empty widget; if False, switch to the content widget.

Return type:

None