spyder.api.shellconnect.mixins#

Mixins for plugins/widgets that are connected to the IPython console.

Classes

ShellConnectMixin()

Mixin to connect any widget or object to an IPython Console shell widget.

ShellConnectPluginMixin()

Mixin to connect a plugin composed of stacked widgets to the shell widgets in the IPython console.

ShellConnectWidgetForStackMixin()

Mixin for widgets added to a stack of those connected to different shells.

class spyder.api.shellconnect.mixins.ShellConnectMixin[source]#

Bases: object

Mixin to connect any widget or object to an IPython Console shell widget.

register_ipythonconsole(ipythonconsole: spyder.plugins.ipythonconsole.plugin.IPythonConsole) None[source]#

Connect this object to the relevant signals of the IPython Console.

Parameters:

ipythonconsole (spyder.plugins.ipythonconsole.plugin.IPythonConsole) – The IPython Console to connect this object to the signals of.

Return type:

None

unregister_ipythonconsole(ipythonconsole: spyder.plugins.ipythonconsole.plugin.IPythonConsole) None[source]#

Disconnect this object from the relevant signals of the IPython Console.

Parameters:

ipythonconsole (spyder.plugins.ipythonconsole.plugin.IPythonConsole) – The IPython Console to disconnect this object from the signals of.

Return type:

None

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

Set as active the stack widget associated to 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_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) None[source]#

Create a new object 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 object associated to a given shell widget.

Parameters:

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

Return type:

None

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

Register an error widget if the shell widget’s kernel failed to start.

Parameters:

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

Return type:

None

class spyder.api.shellconnect.mixins.ShellConnectWidgetForStackMixin[source]#

Bases: object

Mixin for widgets added to a stack of those connected to different shells.

Used for the stacked widgets of ShellConnectMainWidget.

sig_show_empty_message_requested: Signal#

Request that the empty message be shown/hidden.

Parameters:

show_empty_message (bool) – True to show the empty message; False for the normal widget.

__init__() None[source]#

Set up attributes on the mixin.

Return type:

None

is_empty: bool#

If the current widget has content to show.

This attribute is necessary to track whether this widget has content to display.

class spyder.api.shellconnect.mixins.ShellConnectPluginMixin[source]#

Bases: ShellConnectMixin

Mixin to connect a plugin composed of stacked widgets to the shell widgets in the IPython console.

It is assumed that self.get_widget() returns an instance of ShellConnectMainWidget.

on_ipython_console_available() None[source]#

Connect this object to the relevant signals of the IPython Console.

Return type:

None

on_ipython_console_teardown() None[source]#

Disconnect this object from the relevant signals of the IPython Console.

Return type:

None

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

Set as active the stack widget associated to 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_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 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

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

current_widget() QWidget[source]#

Get the widget corresponding to the currently active console tab.

Returns:

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

Return type:

QWidget

get_widget_for_shellwidget(shellwidget: spyder.plugins.ipythonconsole.widgets.ShellWidget) QWidget[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