spyder.api.widgets.menus#

Spyder API menu widgets.

Classes

OptionsMenuSections()

PluginMainWidgetMenus()

PluginMainWidgetOptionsMenu([parent, ...])

Options menu for PluginMainWidget.

SpyderMenu([parent, menu_id, title, ...])

A QMenu subclass to implement additional functionality for Spyder.

SpyderMenuProxyStyle

Style adjustments that can only be done with a proxy style.

class spyder.api.widgets.menus.SpyderMenuProxyStyle[source]#

Bases: QProxyStyle

Style adjustments that can only be done with a proxy style.

pixelMetric(self, metric: QStyle.PixelMetric, option: QStyleOption | None = None, widget: QWidget | None = None) int[source]#
class spyder.api.widgets.menus.SpyderMenu(parent: QWidget | None = None, menu_id: str | None = None, title: str | None = None, min_width: int | None = None, reposition: bool | None = True)[source]#

Bases: QMenu, SpyderFontsMixin

A QMenu subclass to implement additional functionality for Spyder.

clear_actions()[source]#

Remove actions from the menu (including custom references)

Return type:

None.

add_action(action: SpyderAction | T, section: str | None = None, before: str | None = None, before_section: str | None = None, check_before: bool = True, omit_id: bool = False)[source]#

Add action to a given menu section.

Parameters:
  • action (SpyderAction) – The action to add.

  • section (str or None) – The section id in which to insert the action.

  • before (str) – Make the action appear before the given action identifier.

  • before_section (str or None) – Make the item section (if provided) appear before another given section.

  • check_before (bool) – Check if the before action is part of the menu. This is necessary to avoid an infinite recursion when adding unintroduced actions with this method again.

  • omit_id (bool) – If True, then the menu will check if the item to add declares an id, False otherwise. This flag exists only for items added on Spyder 4 plugins. Default: False

get_title()[source]#

Return the title for menu.

get_actions()[source]#

Return a parsed list of menu actions.

Includes MENU_SEPARATOR taking into account the sections defined.

get_sections()[source]#

Return a tuple of menu sections.

render(force=False)[source]#

Create the menu prior to showing it. This takes into account sections and location of menus.

Parameters:

force (bool, optional) – Whether to force rendering the menu.

showEvent(event)[source]#

Call adjustments when the menu is going to be shown.

class spyder.api.widgets.menus.PluginMainWidgetOptionsMenu(parent: QWidget | None = None, menu_id: str | None = None, title: str | None = None, min_width: int | None = None, reposition: bool | None = True)[source]#

Bases: SpyderMenu

Options menu for PluginMainWidget.

render()[source]#

Render the menu’s bottom section as expected.