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
|
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:
PluginMainWidgetMain widget to use in a plugin that shows different content per-console.
It is composed of a
QStackedWidgetto 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:
*args (Any) – Positional arguments to pass to
PluginMainWidget.__init__().set_layout (bool, optional) – Whether to add the created widget to a layout,
Trueby default.**kwargs (Any) – Keyword arguments to pass to
PluginMainWidget.__init__().
- 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:
- 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:
- update_style() None[source]#
Update the stylesheet and style of the stack widget.
Caution
If overriding this method,
supermust 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:
- 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, orNoneif 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:
- close_widget(widget: QWidget) None[source]#
Close the given stacked widget.
- Parameters:
widget (QWidget) – The widget to close.
- Return type:
None