Skip to content

Commit

Permalink
Merge pull request #13709 from goanpeca/enh/add-icons-to-menu-creation
Browse files Browse the repository at this point in the history
PR: Add icon to menu creation mixin
  • Loading branch information
dalthviz committed Sep 3, 2020
2 parents 44c4be0 + be595c8 commit 3055730
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spyder/api/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def add_item_to_menu(self, action_or_menu, menu, section=None,

menu.add_action(action_or_menu, section=section, before=before)

def create_menu(self, name, text=None):
def create_menu(self, name, text=None, icon=None):
"""
Create a menu.
Expand All @@ -358,6 +358,8 @@ def create_menu(self, name, text=None):
Unique str identifier.
text: str
Localized text string.
icon: QIcon,
Icon to use for the menu.
Return: QMenu
Return the created menu.
Expand All @@ -374,6 +376,10 @@ def create_menu(self, name, text=None):
)

menu = SpyderMenu(parent=self, title=text)
if icon is not None:
menu.menuAction().setIconVisibleInMenu(True)
menu.setIcon(icon)

self._menus[name] = menu
return menu

Expand Down

0 comments on commit 3055730

Please sign in to comment.