spyder.api.widgets.main_container#

Main container widget for non-dockable Spyder plugins.

SpyderPluginV2 plugins must provide a CONTAINER_CLASS attribute that is a subclass of PluginMainContainer, if they have additional widgets like status bar items or toolbars.

Classes

PluginMainContainer(name, plugin[, parent])

Main container widget class for non-dockable Spyder plugins.

class spyder.api.widgets.main_container.PluginMainContainer(
name: str,
plugin: SpyderPluginV2,
parent: spyder.app.mainwindow.MainWindow | None = None,
)[source]#

Bases: QWidget, SpyderWidgetMixin

Main container widget class for non-dockable Spyder plugins.

This class is used by non-dockable plugins to be able to contain, parent and store references to other widgets, like status bar widgets, toolbars, context menus, etc.

Important

If a Spyder non-dockable plugins defines a CONTAINER_CLASS it must inherit from this class, :class`PluginMainContainer`.

CONTEXT_NAME: str | None = None#

The name under which to store actions, toolbars, toolbuttons and menus.

This optional attribute defines the context name under which actions, toolbars, toolbuttons and menus should be registered in the Spyder global registry.

If those elements belong to the global scope of the plugin, then this attribute should have a None value, which will use the plugin’s name as the context scope.

sig_free_memory_requested: Signal#

Signal to request the main application garbage-collect deleted objects.

sig_quit_requested: Signal#

Signal to request the main Spyder application quit.

sig_restart_requested: Signal#

Signal to request the main Spyder application quit and restart itself.

sig_redirect_stdio_requested(bool): Signal#

Request the main app redirect standard out/error within file pickers.

This will redirect stdin, stdout, and stderr when using Open, Save, and Browse dialogs within a plugin’s widgets.

Parameters:

enable (bool) – Enable (True) or disable (False) standard input/output redirection.

sig_exception_occurred(PyQt_PyObject): Signal#

Signal to report an exception from a plugin.

Parameters:

error_data (dict[str, str | bool]) –

The dictionary containing error data. The expected keys are:

error_data = {
    "text": str,
    "is_traceback": bool,
    "repo": str,
    "title": str,
    "label": str,
    "steps": str,
}

The is_traceback key indicates if text contains plain text or a Python error traceback.

The title and repo keys indicate how the error data should customize the report dialog and GitHub error submission.

The label and steps keys allow customizing the content of the error dialog.

sig_unmaximize_plugin_requested(), (PyQt_PyObject): Signal#

Request the main window unmaximize the currently maximized plugin, if any.

If emitted without arguments, it’ll unmaximize any plugin.

Parameters:

plugin_instance (SpyderDockablePlugin) – Unmaximize current plugin only if it is not plugin_instance.

__init__(
name: str,
plugin: SpyderPluginV2,
parent: spyder.app.mainwindow.MainWindow | None = None,
) None[source]#

Create a new container class for a plugin.

This method is not meant to be overridden by container subclasses. Use the setup() method instead to instantiate the widgets that this one will contain.

Parameters:
  • name (str) – The name of the plugin, i.e. the SpyderPluginV2.NAME.

  • plugin (SpyderPluginV2) – The plugin object this is to be the container class of.

  • parent (spyder.app.mainwindow.MainWindow | None, optional) – The container’s parent widget, normally the Spyder main window. By default (None), no parent widget (used for testing).

Return type:

None

closeEvent(event: QCloseEvent) None[source]#

Handle closing this container widget.

Parameters:

event (QCloseEvent) – The event object closing this widget.

Return type:

None

setup() None[source]#

Create widgets, toolbars and menus, and perform other setup steps.

Return type:

None

Raises:

NotImplementedError – If the container subclass doesn’t define a setup method.

update_actions() None[source]#

Update the state of exposed actions.

Exposed actions are actions created by the create_action() method.

Return type:

None

Raises:

NotImplementedError – If the subclass doesn’t define an update_actions method.

on_close() None[source]#

Perform actions before the container widget is closed.

Does nothing by default; intended to be overridden for widgets that need to perform actions on close.

Warning

This method must only operate on local attributes.

Return type:

None