spyder.api.preferences#

API to create an entry in Spyder Preferences associated to a given plugin.

Module Attributes

OptionSet

Type alias for a set of keys mapping to valid Spyder configuration values.

Classes

PluginConfigPage(plugin, parent)

A Spyder Preferences page for a single plugin.

SpyderPreferencesTab(parent)

Widget that represents a tab on a preference page.

spyder.api.preferences.OptionSet#

Type alias for a set of keys mapping to valid Spyder configuration values.

A set of spyder.config.types.ConfigurationKeys.

alias of set[str | Tuple[str, …]]

class spyder.api.preferences.SpyderPreferencesTab(parent: SpyderConfigPage)[source]#

Bases: BaseConfigTab

Widget that represents a tab on a preference page.

All calls to spyder.widgets.config.SpyderConfigPage attributes are resolved via delegation.

TITLE: str | None = None#

Name of the tab to display; must be set on the child implementations.

__init__(parent: SpyderConfigPage) None[source]#

Create a new tab on the given parent config page.

Parameters:

parent (spyder.widgets.config.SpyderConfigPage) – The config page the tab will live on, to be this widget’s parent.

Return type:

None

Raises:

ValueError – If TITLE has not been set on the child implementation.

apply_settings() spyder.api.preferences.OptionSet[source]#

Hook to manually apply settings that cannot be applied automatically.

Reimplement this if the configuration tab has complex widgets that cannot be created with any of the self.create_* calls. This call should return a set containing the configuration options that changed.

Returns:

The set of Spyder ConfigurationKeys that were manually applied.

Return type:

OptionSet

is_valid() bool[source]#

Return False if the tab contents are invalid, True otherwise.

This method can be overriden to perform complex checks.

Returns:

Whether the tab contents are valid.

Return type:

bool

__getattr__(self, name: str | None) Any[source]#
setLayout(layout)[source]#

Remove default margins around the layout by default.

class spyder.api.preferences.PluginConfigPage(plugin: SpyderPluginV2, parent: spyder.plugins.preferences.widget.ConfigDialog)[source]#

Bases: SpyderConfigPage

A Spyder Preferences page for a single plugin.

This widget exposes the options a plugin offers for configuration as an entry in Spyder’s Preferences dialog.

__init__(plugin: SpyderPluginV2, parent: spyder.plugins.preferences.widget.ConfigDialog) None[source]#

Create a Spyder Preferences page for a plugin.

Parameters:
  • plugin (SpyderPluginV2) – The plugin to create the configuration page for.

  • parent (spyder.plugins.preferences.widgets.configdialog.ConfigDialog) – The main Spyder Preferences dialog, parent widget to this one.

Return type:

None

aggregate_sections_partials(opts: spyder.api.preferences.OptionSet) None[source]#

Aggregate options by sections in order to notify observers.

Parameters:

opts (OptionSet) – The options to aggregate by section.

Return type:

None

get_name() str[source]#

Return plugin name to use in preferences page title and message boxes.

Normally you do not have to reimplement it, as the plugin name in the preferences page will be the same as the plugin title.

Returns:

The plugin this preference page corresponds to.

Return type:

str

get_icon() QIcon[source]#

Return the plugin icon to use in the preferences page.

Normally you do not have to reimplement it, as the plugin icon in the preferences page will be the same as the main plugin icon.

Returns:

The plugin’s icon.

Return type:

QIcon

setup_page() None[source]#

Set up the configuration page widget.

You need to implement this method to set the layout of the preferences page.

For example:

layout = QVBoxLayout()
layout.addWidget(...)
...
self.setLayout(layout)
Return type:

None

apply_settings() spyder.api.preferences.OptionSet[source]#

Hook to manually apply settings that cannot be applied automatically.

Reimplement this if the configuration tab has complex widgets that cannot be created with any of the self.create_* calls. This call should return a set containing the configuration options that changed.

Returns:

The set of Spyder ConfigurationKeys that were manually applied.

Return type:

OptionSet