code stringlengths 9 189k | meta_data.file_name stringclasses 538
values | meta_data.module stringclasses 202
values | meta_data.contains_class bool 2
classes | meta_data.contains_function bool 2
classes | meta_data.file_imports listlengths 0 97 | meta_data.start_line int64 -1 6.71k | meta_data.end_line int64 -1 6.74k |
|---|---|---|---|---|---|---|---|
Parameters
----------
before_section: str or None
Make `section` appear before another one.
"""
inserted_before_other = False
if before_section is not None:
if before_section in self._sections:
# If before_section was already introduced, w... | menus.py | spyder.spyder.api.widgets | false | false | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 65 | 95 |
# Check if section should be inserted after another one, according to
# what we have in _after_sections.
after_section = self._after_sections.pop(section, None)
if after_section is not None:
if not inserted_before_other:
# Insert section to the right of after_section... | menus.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 317 | 342 |
def _set_icons(self):
"""
Unset menu icons for app menus and set them for regular menus.
This is necessary only for Mac to follow its Human Interface
Guidelines (HIG), which don't recommend icons in app menus.
"""
if sys.platform == "darwin":
if self.APP_MENU... | menus.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 340 | 371 |
# Set the right background color This is the only way to do it!
css['QWidget:disabled QMenu'].setValues(
backgroundColor=QStylePalette.COLOR_BACKGROUND_3,
)
# Add padding around separators to prevent that hovering on items hides
# them.
css["QMenu::separator"].setVal... | menus.py | spyder.spyder.api.widgets | false | false | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 368 | 395 |
# Set hover and pressed state of items
for state in ['selected', 'pressed']:
if state == 'selected':
bg_color = QStylePalette.COLOR_BACKGROUND_4
else:
bg_color = QStylePalette.COLOR_BACKGROUND_5
css[f"QMenu::item:{state}"].setValues(
... | menus.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 397 | 438 |
class PluginMainWidgetOptionsMenu(SpyderMenu):
"""
Options menu for PluginMainWidget.
"""
def render(self):
"""Render the menu's bottom section as expected."""
if self._dirty:
self.clear()
self._add_missing_actions()
bottom = OptionsMenuSections.Bott... | menus.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"from typing import Optional, Union, TypeVar",
"import qstylizer.style",
"from qtpy.QtWidgets import QAction, QMenu, QWidget",
"from spyder.api.config.fonts import SpyderFontType, SpyderFontsMixin",
"from spyder.utils.qthelpers import add_actions, set_menu_icons, SpyderAction",
"from spyde... | 441 | 469 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Spyder combobox widgets.
Use these widgets for any combobox you want to add to Spyder.
"""
# Standard library imports
import sys
# Third-party imports
import q... | comboboxes.py | spyder.spyder.api.widgets | false | false | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 1 | 30 |
class _SpyderComboBoxDelegate(QStyledItemDelegate):
"""
Delegate to make separators color follow our theme.
Adapted from https://stackoverflow.com/a/33464045/438386
"""
def paint(self, painter, option, index):
data = index.data(Qt.AccessibleDescriptionRole)
if data and data == "sep... | comboboxes.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 33 | 58 |
class _SpyderComboBoxLineEdit(QLineEdit):
"""Dummy lineedit used for non-editable comboboxes."""
sig_mouse_clicked = Signal()
def __init__(self, parent):
super().__init__(parent)
# Fix style issues
css = qstylizer.style.StyleSheet()
css.QLineEdit.setValues(
# T... | comboboxes.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 61 | 89 |
class _SpyderComboBoxMixin:
"""Mixin with the basic style and functionality for our comboboxes."""
def __init__(self):
# Style
self._css = self._generate_stylesheet()
self.setStyleSheet(self._css.toString())
def contextMenuEvent(self, event):
# Prevent showing context menu... | comboboxes.py | spyder.spyder.api.widgets | true | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 92 | 127 |
# Make color of hovered combobox items match the one used in other
# Spyder widgets
css["QComboBox QAbstractItemView::item:selected:active"].setValues(
backgroundColor=QStylePalette.COLOR_BACKGROUND_3,
)
return css | comboboxes.py | spyder.spyder.api.widgets | false | false | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 129 | 135 |
class SpyderComboBox(QComboBox, _SpyderComboBoxMixin):
"""Combobox widget for Spyder when its items don't have icons."""
def __init__(self, parent=None):
super().__init__(parent)
self.is_editable = None
self._is_shown = False
self._is_popup_shown = False
# This is also... | comboboxes.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 138 | 174 |
self._is_shown = True
super().showEvent(event)
def showPopup(self):
"""Adjustments when the popup is shown."""
super().showPopup()
if sys.platform == "darwin":
# Reposition popup to display it in the right place.
# Solution from https://forum.qt.io/post/349... | comboboxes.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 174 | 214 |
class SpyderComboBoxWithIcons(SpyderComboBox):
""""Combobox widget for Spyder when its items have icons."""
def __init__(self, parent=None):
super().__init__(parent)
# Padding is not necessary because icons give items enough of it.
self._css["QComboBox QAbstractItemView::item"].setValu... | comboboxes.py | spyder.spyder.api.widgets | false | true | [
"import sys",
"import qstylizer.style",
"from qtpy.QtCore import QSize, Qt, Signal",
"from qtpy.QtGui import QColor",
"from qtpy.QtWidgets import (",
"from spyder.utils.palette import QStylePalette",
"from spyder.utils.stylesheet import AppStyle, WIN"
] | 217 | 250 |
class SpyderPluginV2(QObject, SpyderActionMixin, SpyderConfigurationObserver,
SpyderPluginObserver):
"""
A Spyder plugin to extend functionality without a dockable widget.
If you want to create a plugin that adds a new pane, please use
SpyderDockablePlugin.
"""
# --- API: ... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 51 | 73 |
# List of optional plugin dependencies.
# Example: [Plugins.Plots, Plugins.IPythonConsole, ...].
# These values are defined in the `Plugins` class present in this file.
# A plugin might be performing actions when connectiong to other plugins,
# but the main functionality of the plugin does not depend on... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 75 | 99 |
# Use a separate configuration file for the plugin.
CONF_FILE = True
# Define configuration defaults if using a separate file.
# List of tuples, with the first item in the tuple being the section
# name and the second item being the default options dictionary.
#
# CONF_DEFAULTS_EXAMPLE = [
... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 98 | 130 |
# Some plugins may add configuration options for other plugins.
# Example:
# ADDITIONAL_CONF_OPTIONS = {'section': <new value to add>}
ADDITIONAL_CONF_OPTIONS = None
# Define additional configurable options (via a tab) to
# another's plugin configuration page. All configuration tabs should
# in... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 127 | 160 |
# Define if a plugin can be disabled in preferences.
# If False, the plugin is considered "core" and therefore it cannot be
# disabled. Default: True
CAN_BE_DISABLED = True
# --- API: Signals -------------------------------------------------------
# -------------------------------------------------... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 157 | 198 |
Parameters
----------
message: str
The actual message to display.
timeout: int
The timeout before the message disappears.
"""
sig_redirect_stdio_requested = Signal(bool)
"""
This signal can be emitted to request the main application to redirect
standard output/error when... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 192 | 244 |
sig_mainwindow_resized = Signal("QResizeEvent")
"""
This signal is emitted when the main window is resized.
Parameters
----------
resize_event: QResizeEvent
The event triggered on main window resize.
Notes
-----
To be used by plugins tracking main window size changes.
"""
... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 242 | 290 |
Parameters
----------
window_state: Qt.WindowStates
The window state.
"""
# --- Private attributes -------------------------------------------------
# ------------------------------------------------------------------------
# Define configuration name map for plugin to split configurati... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 192 | 226 |
# Attribute used to access the action, toolbar, toolbutton and menu
# registries
self.PLUGIN_NAME = self.NAME
if self.CONTAINER_CLASS is not None:
self._container = container = self.CONTAINER_CLASS(
name=self.NAME,
plugin=self,
parent=... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 318 | 353 |
# Load the custom images of the plugin
if self.IMG_PATH:
plugin_path = osp.join(self.get_path(), self.IMG_PATH)
IMAGE_PATH_MANAGER.add_image_path(plugin_path)
# --- Private methods ----------------------------------------------------
# -------------------------------------------... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 350 | 389 |
if self._conf is not None:
self._conf.unregister_plugin(self)
self._container = None
self.is_compatible = None
self.is_registered = False
# --- API: available methods ---------------------------------------------
# -----------------------------------------------------------... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 384 | 433 |
if plugin_name in full_set or Plugins.All in full_set:
try:
return self._main.get_plugin(plugin_name, error=error)
except SpyderAPIError as e:
if plugin_name in optional:
return None
else:
raise e
els... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 435 | 470 |
def get_conf(self, option, default=NoDefault, section=None):
"""
Get an option from Spyder configuration system.
Parameters
----------
option: str
Name of the option to get its value from.
default: bool, int, str, tuple, list, dict, NoDefault
Valu... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 472 | 505 |
Parameters
----------
option: str
Name of the option (e.g. 'case_sensitive')
value: bool, int, str, tuple, list, dict
Value to save in the configuration system, passed as a
Python object.
section: str
Section in the configuration system, e.... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 192 | 223 |
def remove_conf(self, option, section=None):
"""
Delete an option in the Spyder configuration system.
Parameters
----------
option: Union[str, Tuple[str, ...]]
Name of the option, either a string or a tuple of strings.
section: str
Section in the ... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 536 | 568 |
def disable_conf(self, option, section=None):
"""
Disable notifications for an option in the Spyder configuration system.
Parameters
----------
option: Union[str, Tuple[str, ...]]
Name of the option, either a string or a tuple of strings.
section: str
... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 566 | 604 |
@Slot(str)
@Slot(str, int)
def show_status_message(self, message, timeout=0):
"""
Show message in status bar.
Parameters
----------
message: str
Message to display in the status bar.
timeout: int
Amount of time to display the message.
... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 606 | 653 |
def get_color_scheme(self):
"""
Get the current color scheme.
Returns
-------
dict
Dictionary with properties and colors of the color scheme
used in the Editor.
Notes
-----
This is useful to set the color scheme of all instances o... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 651 | 692 |
@classmethod
def get_font(cls, font_type):
"""
Return one of font types used in Spyder.
Parameters
----------
font_type: str
There are three types of font types in Spyder:
SpyderFontType.Monospace, used in the Editor, IPython console,
and ... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 689 | 723 |
return get_font(option=font_type, font_size_delta=font_size_delta)
def get_command_line_options(self):
"""
Get command line options passed by the user when they started
Spyder in a system terminal.
See app/cli_options.py for the option names.
"""
if self._main is no... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 723 | 771 |
Notes
-----
This method needs to be decorated with `staticmethod`.
"""
raise NotImplementedError('A plugin description must be defined!')
@classmethod
def get_icon(cls):
"""
Return the plugin associated icon.
Returns
-------
QIcon
... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 228 | 273 |
Returns
-------
(bool, str)
The first value tells Spyder if the plugin has passed the
compatibility test defined in this method. The second value
is a message that must explain users why the plugin was
found to be incompatible (e.g. 'This plugin does not w... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 486 | 525 |
def on_close(self, cancelable=False):
"""
Perform actions before the plugin is closed.
This method **must** only operate on local attributes and not other
plugins.
"""
if hasattr(self, 'unregister'):
warnings.warn('The unregister method was deprecated and it ... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 851 | 894 |
def after_container_creation(self):
"""
Perform necessary operations before setting up the container.
This must be reimplemented by plugins whose containers emit signals in
on_option_update that need to be connected before applying those
options to our config system.
"""... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 896 | 919 |
class SpyderDockablePlugin(SpyderPluginV2):
"""
A Spyder plugin to enhance functionality with a dockable widget.
"""
# --- API: Mandatory attributes ------------------------------------------
# ------------------------------------------------------------------------
# This is the main widget of ... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 922 | 956 |
sig_toggle_view_changed = Signal(bool)
"""
This action is emitted to inform the visibility of a dockable plugin
has changed.
This is triggered by checking/unchecking the entry for a pane in the
`View > Panes` menu.
Parameters
----------
visible: bool
New visibility of the dockw... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 953 | 996 |
self.CONTAINER_CLASS = self.WIDGET_CLASS
super().__init__(parent, configuration=configuration)
# Defined on mainwindow.py
self._shortcut = None
# Widget setup
# --------------------------------------------------------------------
self._widget = self._container
w... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 992 | 1,025 |
# --- API: available methods ---------------------------------------------
# ------------------------------------------------------------------------
def before_long_process(self, message):
"""
Show a message in main window's status bar, change the mouse pointer
to Qt.WaitCursor and star... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 391 | 432 |
return self._widget
def update_title(self):
"""
Update plugin title, i.e. dockwidget or window title.
"""
self.get_widget().update_title()
def update_margins(self, margin):
"""
Update margins of main widget inside dockable plugin.
"""
self.get_wi... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 1,062 | 1,108 |
def create_dockwidget(self, mainwindow):
return self.get_widget().create_dockwidget(mainwindow)
def create_window(self):
self.get_widget().create_window()
def close_window(self, save_undocked=False):
self.get_widget().close_window(save_undocked=save_undocked)
def change_visibility... | new_api.py | spyder.spyder.api.plugins | false | true | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 1,104 | 1,117 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
New API for plugins.
All plugins in Spyder 5+ must inherit from the classes present in this file.
"""
# Standard library imports
from collections import Ordered... | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 1 | 51 |
# Logging
logger = logging.getLogger(__name__)
# Code for: class SpyderPluginV2(QObject, SpyderActionMixin, SpyderConfigurationObserver,
# Code for: class SpyderDockablePlugin(SpyderPluginV2): | new_api.py | spyder.spyder.api.plugins | false | false | [
"from collections import OrderedDict",
"import inspect",
"import logging",
"import os",
"import os.path as osp",
"import sys",
"from typing import List, Union",
"import warnings",
"from qtpy.QtCore import QObject, Qt, Signal, Slot",
"from qtpy.QtGui import QCursor",
"from qtpy.QtWidgets import Q... | 47 | 54 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
spyder.api.plugins
==================
Here, 'plugins' are Qt objects that can make changes to Spyder's main window
and call other plugins directly.
There are tw... | __init__.py | spyder.spyder.api.plugins | false | false | [
"from .enum import Plugins, DockablePlugins # noqa",
"from .old_api import SpyderPlugin, SpyderPluginWidget # noqa",
"from .new_api import SpyderDockablePlugin, SpyderPluginV2 # noqa"
] | 1 | 26 |
class BasePlugin(BasePluginMixin):
"""
Basic functionality for Spyder plugins.
WARNING: Don't override any methods or attributes present here!
"""
# Use this signal to display a message in the status bar.
# str: The message you want to display
# int: Amount of time to display the message
... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 28 | 71 |
@Slot(str, object)
def set_option(self, option, value, section=None,
recursive_notification=True):
"""
Set an option in Spyder configuration file.
Parameters
----------
option: str
Name of the option (e.g. 'case_sensitive')
value: bool,... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 73 | 116 |
def remove_option(self, option, section=None):
"""
Remove an option from the Spyder configuration file.
Parameters
----------
option: Union[str, Tuple[str, ...]]
A string or a Tuple of strings containing an option name to remove.
section: Optional[str]
... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 114 | 151 |
class SpyderPlugin(BasePlugin):
"""
Spyder plugin class.
All plugins *must* inherit this class and reimplement its interface.
"""
# ---------------------------- ATTRIBUTES ---------------------------------
# Name of the configuration section that's going to be
# used to record the plugin's... | old_api.py | spyder.spyder.api.plugins | false | false | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 154 | 191 |
# Define configuration version if using a separate file
# Status: Optional
#
# IMPORTANT NOTES:
# 1. If you want to *change* the default value of a current option, you
# need to do a MINOR update in config version, e.g. from 3.0.0 to 3.1.0
# 2. If you want to *remove* options that are no long... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 193 | 223 |
class BasePluginWidget(QWidget, BasePluginWidgetMixin):
"""
Basic functionality for Spyder plugin widgets.
WARNING: Don't override any methods or attributes present here!
"""
# Signal used to update the plugin title when it's undocked
sig_update_plugin_title = Signal()
def __init__(self, ... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 229 | 265 |
Examples
--------
>>> self.tabify(self.main.variableexplorer)
>>> self.tabify(self.main.ipyconsole)
Notes
-----
The names of variables associated with each of the core plugins
can be found in the `setup` method of `MainWindow`, present in
`spyder/app/main... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 262 | 304 |
Parameters
----------
qaction_or_qshortcut: QAction or QShortcut
QAction to register the shortcut for or QShortcut.
context: str
Name of the plugin this shortcut applies to. For instance,
if you pass 'Editor' as context, the shortcut will only
work... | old_api.py | spyder.spyder.api.plugins | false | false | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 64 | 93 |
Parameters
----------
qaction_or_qshortcut: QAction or QShortcut
QAction to register the shortcut for or QShortcut.
context: str
Name of the plugin this shortcut applies to. For instance,
if you pass 'Editor' as context, the shortcut will only
work... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 64 | 97 |
Parameters
----------
widget: QWidget
Widget to register shortcuts for.
Notes
-----
The widget interface must have a method called
`get_shortcut_data` for this to work. Please see
`spyder/widgets/findreplace.py` for an example.
"""
for... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 64 | 111 |
def switch_to_plugin(self):
"""
Switch to this plugin.
Notes
-----
This operation unmaximizes the current plugin (if any), raises
this plugin to view (if it's hidden) and gives it focus (if
possible).
"""
super(BasePluginWidget, self)._switch_to_p... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 416 | 426 |
class SpyderPluginWidget(SpyderPlugin, BasePluginWidget):
"""
Spyder plugin widget class.
All plugin widgets *must* inherit this class and reimplement its interface.
"""
# ---------------------------- ATTRIBUTES ---------------------------------
# Path for images relative to the plugin path
... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 429 | 485 |
def get_focus_widget(self):
"""
Get the plugin widget to give focus to.
Returns
-------
QWidget
QWidget to give focus to.
Notes
-----
This is applied when plugin's dockwidget is raised on top-level.
"""
pass
def closing_p... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 483 | 538 |
def register_plugin(self):
"""
Register plugin in Spyder's main window and connect it to other
plugins.
Notes
-----
Below is the minimal call necessary to register the plugin. If
you override this method, please don't forget to make that call
here too.
... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 535 | 582 |
Parameters
----------
checked: bool
Is the entry in `View > Panes` checked or not?
Notes
-----
Redefining this method can be useful to execute certain actions
when the plugin is made visible. For an example, please see
`spyder/plugins/ipythonconsole/p... | old_api.py | spyder.spyder.api.plugins | false | true | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 64 | 87 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Old API for plugins.
These plugins were supported until Spyder 4, but they will be deprecated in
the future. Please don't rely on them for new plugins and use in... | old_api.py | spyder.spyder.api.plugins | false | false | [
"from qtpy.QtCore import Signal, Slot",
"from qtpy.QtWidgets import QWidget",
"from spyder.config.user import NoDefault",
"from spyder.plugins.base import BasePluginMixin, BasePluginWidgetMixin",
"from spyder.utils.icon_manager import ima"
] | 1 | 40 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Enum of Spyder internal plugins."""
class Plugins:
"""
Convenience class for accessing Spyder internal plugins.
"""
All = "all" # Wildcard to p... | enum.py | spyder.spyder.api.plugins | true | false | [] | 1 | 45 |
class DockablePlugins:
Console = 'internal_console'
Debugger = 'debugger'
Editor = 'editor'
Explorer = 'explorer'
Find = 'find_in_files'
Help = 'help'
History = 'historylog'
IPythonConsole = 'ipython_console'
OnlineHelp = 'onlinehelp'
OutlineExplorer = 'outline_explorer'
Plot... | enum.py | spyder.spyder.api.plugins | true | false | [] | 48 | 63 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Spyder API plugin registration decorators.
"""
# Standard library imports
import functools
from typing import Callable, Optional
import inspect
def on_plugin_a... | decorators.py | spyder.spyder.api.plugin_registration | false | true | [
"import functools",
"from typing import Callable, Optional",
"import inspect"
] | 1 | 48 |
def on_plugin_teardown(func: Callable = None,
plugin: Optional[str] = None):
"""
Method decorator used to handle plugin teardown on Spyder.
This decorator will be called **before** the specified plugin is deleted
and also **before** the plugin that uses the decorator is destroyed... | decorators.py | spyder.spyder.api.plugin_registration | false | false | [
"import functools",
"from typing import Callable, Optional",
"import inspect"
] | 51 | 83 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Spyder API plugin registration mixins.
"""
# Standard library imports
import logging
from spyder.api.exceptions import SpyderAPIError
from spyder.api.plugins im... | mixins.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from spyder.api.exceptions import SpyderAPIError",
"from spyder.api.plugins import Plugins"
] | 1 | 17 |
class SpyderPluginObserver:
"""
This mixin enables a class to receive notifications when a plugin
is available, by registering methods using the
:function:`spyder.api.plugin_registration.decorators.on_plugin_available`
decorator.
When any of the requested plugins is ready, the corresponding reg... | mixins.py | spyder.spyder.api.plugin_registration | true | true | [
"import logging",
"from spyder.api.exceptions import SpyderAPIError",
"from spyder.api.plugins import Plugins"
] | 20 | 56 |
logger.debug(
f'Method {method_name} is watching plugin {plugin_listen}'
)
self._plugin_listeners[plugin_listen] = method_name
if hasattr(method, '_plugin_teardown'):
plugin_teardown = method._plugin_teardown
# Check if pl... | mixins.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from spyder.api.exceptions import SpyderAPIError",
"from spyder.api.plugins import Plugins"
] | 58 | 87 |
def _on_plugin_available(self, plugin: str):
"""
Handle plugin availability and redirect it to plugin-specific
startup handlers.
Parameters
----------
plugin: str
Name of the plugin that was notified as available.
"""
# Call plugin specific ha... | mixins.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from spyder.api.exceptions import SpyderAPIError",
"from spyder.api.plugins import Plugins"
] | 84 | 122 |
class PreferencesAdapter(SpyderConfigurationAccessor):
# Fake class constants used to register the configuration page
CONF_WIDGET_CLASS = PluginsConfigPage
NAME = 'plugin_registry'
CONF_VERSION = None
ADDITIONAL_CONF_OPTIONS = None
ADDITIONAL_CONF_TABS = None
CONF_SECTION = ""
def apply... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 42 | 55 |
class SpyderPluginRegistry(QObject, PreferencesAdapter):
"""
Global plugin registry.
This class handles a plugin initialization/teardown lifetime, including
notifications when a plugin is available or not.
This registry alleviates the limitations of a topological sort-based
plugin initializati... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 58 | 101 |
# Dictionary that maps a plugin name to a list of the plugin names
# that the plugin depends on.
self.plugin_dependencies = {} # type: Dict[str, Dict[str, List[str]]]
# Plugin dictionary mapped by their names
self.plugin_registry = {} # type: Dict[str, SpyderPluginClass]
# Di... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 99 | 128 |
# This is used to allow disabling external plugins through Preferences
self._external_plugins_conf_section = "external_plugins"
# ------------------------- PRIVATE API -----------------------------------
def _update_dependents(self, plugin: str, dependent_plugin: str, key: str):
"""Add `depende... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 127 | 146 |
def _update_plugin_info(self, plugin_name: str,
required_plugins: List[str],
optional_plugins: List[str]):
"""Update the dependencies and dependents of `plugin_name`."""
for plugin in required_plugins:
self._update_dependencies(plugin_n... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 148 | 180 |
for plugin in list(optional_plugins):
if plugin == Plugins.All:
optional_plugins = list(set(optional_plugins + ALL_PLUGINS))
# Update plugin dependency information
self._update_plugin_info(plugin_name, required_plugins,
optional_plugins)
... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 178 | 206 |
if external:
# These attributes come from spyder.app.find_plugins
module = PluginClass._spyder_module_name
package_name = PluginClass._spyder_package_name
version = PluginClass._spyder_version
description = plugin_instance.get_description()
depende... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 208 | 238 |
# Register plugin in the registry
self.plugin_registry[plugin_name] = plugin_instance
# Register the name of the plugin under the external or
# internal plugin set
if external:
self.external_plugins |= {plugin_name}
else:
self.internal_plugins |= {plugin_... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 237 | 268 |
def _notify_plugin_teardown(self, plugin_name: str):
"""Notify dependents of a plugin that is going to be unavailable."""
plugin_dependents = self.plugin_dependents.get(plugin_name, {})
required_plugins = plugin_dependents.get('requires', [])
optional_plugins = plugin_dependents.get('opt... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 270 | 295 |
# -------------------------- PUBLIC API -----------------------------------
def register_plugin(
self, main_window: Any,
PluginClass: Type[SpyderPluginClass],
*args: tuple, external: bool = False,
**kwargs: dict) -> SpyderPluginClass:
"""
Register a pl... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 297 | 331 |
Raises
------
TypeError
If the `PluginClass` does not inherit from any of
`spyder.app.registry.SpyderPluginClass`
Notes
-----
The optional `*args` and `**kwargs` will be removed once all
plugins are migrated.
"""
if not issubclass(... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 327 | 358 |
Parameters
----------
plugin_name: str
Name of the plugin that is available.
notify_main: bool
If True, then a signal is emitted to the main window to perform
further registration steps.
omit_conf: bool
If True, then the main window is inst... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 80 | 113 |
def can_delete_plugin(self, plugin_name: str) -> bool:
"""
Check if a plugin from the registry can be deleted by its name.
Paremeters
----------
plugin_name: str
Name of the plugin to check for deletion.
Returns
-------
plugin_deleted: bool
... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 395 | 435 |
Returns
-------
None.
"""
plugin_instance = self.plugin_registry[plugin_name]
if isinstance(plugin_instance, SpyderDockablePlugin):
# Close undocked plugin if needed and save undocked state
plugin_instance.close_window(save_undocked=save_undocked)
... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 322 | 357 |
Returns
-------
plugin_deleted: bool
True if the registry was able to teardown and remove the plugin.
False otherwise.
"""
logger.debug(f'Deleting plugin {plugin_name}')
plugin_instance = self.plugin_registry[plugin_name]
# Determine if plugin can... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 322 | 362 |
# Disconnect depending plugins from the plugin to delete
self._notify_plugin_teardown(plugin_name)
# Perform plugin closure tasks
try:
plugin_instance.on_close(True)
except RuntimeError:
pass
elif isinstance(plugin_instance, Sp... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 510 | 540 |
for plugin in self.plugin_dependencies:
all_plugin_dependencies = self.plugin_dependencies[plugin]
for key in {'requires', 'optional'}:
plugin_dependencies = all_plugin_dependencies.get(key, [])
if plugin_name in plugin_dependencies:
plugin_dep... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 542 | 582 |
Parameters
----------
excluding: Optional[Set[str]]
A set that lists plugins (by name) that will not be deleted.
Returns
-------
bool
True if all plugins can be closed. False otherwise.
"""
excluding = excluding or set({})
can_clos... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 80 | 119 |
Returns
-------
all_deleted: bool
True if all the plugins were closed and deleted. False otherwise.
"""
excluding = excluding or set({})
can_close = True
# Check if all the plugins can be closed
can_close = self.can_delete_all_plugins(excluding=exclud... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 322 | 350 |
if not can_close:
return False
# Delete Spyder 4 internal plugins
for plugin_name in set(self.internal_plugins):
if plugin_name not in excluding:
plugin_instance = self.plugin_registry[plugin_name]
if isinstance(plugin_instance, SpyderPlugin):
... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 652 | 679 |
if not can_close and not close_immediately:
return False
# Delete Spyder 5 internal plugins
for plugin_name in set(self.internal_plugins):
if plugin_name not in excluding:
plugin_instance = self.plugin_registry[plugin_name]
if isinstance(plugin_in... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 636 | 679 |
def set_plugin_enabled(self, plugin_name: str):
"""
Add a plugin name to the set of enabled plugins.
Parameters
----------
plugin_name: str
Name of the plugin to add.
"""
self.enabled_plugins |= {plugin_name}
def is_plugin_enabled(self, plugin_na... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 719 | 767 |
# Dictionary that maps a plugin name to a list of the plugin names
# that the plugin depends on.
self.plugin_dependencies = {} # type: Dict[str, Dict[str, List[str]]]
# Plugin dictionary mapped by their names
self.plugin_registry = {} # type: Dict[str, SpyderPluginClass]
# Di... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 99 | 139 |
def set_main(self, main):
self.main = main
def get_icon(self):
return ima.icon('plugins')
def get_name(self):
return _('Plugins')
def __contains__(self, plugin_name: str) -> bool:
"""
Determine if a plugin name is contained in the registry.
Parameters
... | registry.py | spyder.spyder.api.plugin_registration | false | true | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 805 | 832 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Global plugin registry."""
# Standard library imports
import logging
from typing import Dict, List, Union, Type, Any, Set, Optional
# Third-party library imports... | registry.py | spyder.spyder.api.plugin_registration | false | false | [
"import logging",
"from typing import Dict, List, Union, Type, Any, Set, Optional",
"from qtpy.QtCore import QObject, Signal",
"from spyder import dependencies",
"from spyder.config.base import _, running_under_pytest",
"from spyder.config.manager import CONF",
"from spyder.api.config.mixins import Spyd... | 1 | 48 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Plugin registry configuration page."""
# Third party imports
from pyuca import Collator
from qtpy.QtWidgets import QVBoxLayout, QLabel
# Local imports
from spyde... | _confpage.py | spyder.spyder.api.plugin_registration | false | false | [
"from pyuca import Collator",
"from qtpy.QtWidgets import QVBoxLayout, QLabel",
"from spyder.api.preferences import PluginConfigPage",
"from spyder.config.base import _",
"from spyder.widgets.elementstable import ElementsTable"
] | 1 | 16 |
class PluginsConfigPage(PluginConfigPage):
def setup_page(self):
newcb = self.create_checkbox
self.plugins_checkboxes = {}
header_label = QLabel(
_("Disable a Spyder plugin (external or built-in) to prevent it "
"from loading until re-enabled here, to simplify the... | _confpage.py | spyder.spyder.api.plugin_registration | false | true | [
"from pyuca import Collator",
"from qtpy.QtWidgets import QVBoxLayout, QLabel",
"from spyder.api.preferences import PluginConfigPage",
"from spyder.config.base import _",
"from spyder.widgets.elementstable import ElementsTable"
] | 19 | 48 |
internal_elements.append(
dict(
title=PluginClass.get_name(),
description=PluginClass.get_description(),
icon=PluginClass.get_icon(),
widget=cb,
additional_info=_("Built-in")
)
... | _confpage.py | spyder.spyder.api.plugin_registration | false | false | [
"from pyuca import Collator",
"from qtpy.QtWidgets import QVBoxLayout, QLabel",
"from spyder.api.preferences import PluginConfigPage",
"from spyder.config.base import _",
"from spyder.widgets.elementstable import ElementsTable"
] | 50 | 87 |
self.plugins_checkboxes[plugin_name] = (cb.checkbox, plugin_state)
# Sort elements by title for easy searching
collator = Collator()
internal_elements.sort(key=lambda e: collator.sort_key(e['title']))
external_elements.sort(key=lambda e: collator.sort_key(e['title']))
# Build p... | _confpage.py | spyder.spyder.api.plugin_registration | false | true | [
"from pyuca import Collator",
"from qtpy.QtWidgets import QVBoxLayout, QLabel",
"from spyder.api.preferences import PluginConfigPage",
"from spyder.config.base import _",
"from spyder.widgets.elementstable import ElementsTable"
] | 60 | 93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.