spyder.api.widgets.toolbars#
Spyder API toolbar widgets.
Module Attributes
Type alias for the set of supported objects that can be toolbar items. |
|
Type alias for the full tuple entry in the list of toolbar items. |
Classes
|
A Spyder main application toolbar. |
|
A Spyder dockable plugin toolbar. |
|
This class provides toolbars with some predefined functionality. |
Pseudo-enum listing possible locations for a toolbar. |
|
Proxy style class to control the style of Spyder toolbars. |
- spyder.api.widgets.toolbars.ToolbarItem#
Type alias for the set of supported objects that can be toolbar items.
alias of
SpyderAction|QWidget
- spyder.api.widgets.toolbars.ToolbarItemEntry#
Type alias for the full tuple entry in the list of toolbar items.
alias of
tuple[SpyderAction|QWidget,str|None,str|None,str|None]
- class spyder.api.widgets.toolbars.ToolbarLocation[source]#
Bases:
objectPseudo-enum listing possible locations for a toolbar.
- Top: ToolBarArea = 4#
Toolbar at the top of the layout.
- Bottom: ToolBarArea = 8#
Toolbar at the bottom of the layout.
- class spyder.api.widgets.toolbars.ToolbarStyle[source]#
Bases:
QProxyStyleProxy style class to control the style of Spyder toolbars.
Deprecated since version 6.2: This class will be renamed to the private
_ToolbarStylein Spyder 6.2, while the current public name will become an alias raising aDeprecationWarningon use, and removed in 7.0.It was never intended to be used directly by plugins, and its functionality is automatically inherited by using the appropriate
ApplicationToolbarandMainWidgetToolbarclasses.- TYPE: Literal['Application'] | Literal['MainWidget'] | None = None#
The toolbar type; must be either “Application” or “MainWidget”.
- pixelMetric(
- pm: PixelMetric,
- option: QStyleOption,
- widget: QWidget,
Adjust size of toolbar extension button (in pixels).
From Stack Overflow.
This is a callback intended to be called internally by Qt.
- Parameters:
pm (PixelMetric) – The pixel metric to calculate.
option (QStyleOption | None, optional) – The current style options, or
None(default).widget (QWidget | None, optional) – The widget the pixel metric will be used for, or
None(default).
- Returns:
The resulting pixel metric value, used internally by Qt.
- Return type:
- Raises:
SpyderAPIError – If
TYPEis not"Application"or"MainWidget", as then this style would do nothing.
- class spyder.api.widgets.toolbars.SpyderToolbar(parent: QWidget | None, title: str)[source]#
Bases:
QToolBarThis class provides toolbars with some predefined functionality.
Caution
This class isn’t intended to be used directly; use its subclasses
ApplicationToolbarandMainWidgetToolbarinstead.- add_item(
- action_or_widget: spyder.api.widgets.toolbars.ToolbarItem,
- section: str | None = None,
- before: str | None = None,
- before_section: str | None = None,
- omit_id: bool = False,
Add action or widget item to the given toolbar
section.- Parameters:
action_or_widget (ToolbarItem) – The item to add to the toolbar.
section (str | None, optional) – The section id in which to insert the
action_or_widget, orNone(default) for no section.before (str | None, optional) – Make the
action_or_widgetappear before the action with the identifierbefore. IfNone(default), add it to the end. Ifbeforeis notNone,before_sectionwill be ignored.before_section (str | None, optional) – Make the
sectionappear prior tobefore_section. IfNone(the default), add the section to the end. If you provide abeforeaction, the new action will be placed before this one, so the section option will be ignored, since the action will now be placed in the same section as thebeforeaction.omit_id (bool, optional) – If
False, the default, then the toolbar will check ifaction.action_idexists and is set to a string, and raise anSpyderAPIErrorif either is not the case. IfTrue, it will add theaction_or_widgetanyway.
- Return type:
None
- Raises:
SpyderAPIError – If
omit_idisFalse(the default) andaction_or_widget.action_iddoes not exist or is not set to a string.
- class spyder.api.widgets.toolbars.ApplicationToolbar(parent: QMainWindow, toolbar_id: str, title: str)[source]#
Bases:
SpyderToolbarA Spyder main application toolbar.
These toolbars are placed above all Spyder dockable plugins in the interface.
- __init__(
- parent: QMainWindow,
- toolbar_id: str,
- title: str,
Create a main Spyder application toolbar.
- Parameters:
parent (QMainWindow) – The parent main window of this toolbar.
toolbar_id (str) – The unique string identifier of this toolbar.
title (str) – The localized name of this toolbar, displayed in the interface.
- Return type:
None
- ID: str | None = None#
Unique string toolbar identifier.
This is used by Qt to be able to save and restore the state of widgets.