Skip to content

Commit

Permalink
API: Make render method of SpyderMenu public
Browse files Browse the repository at this point in the history
Also, make it run the _set_icons method because it's necessary after
calling render manually. That will also avoid calling _set_icons
externally.
  • Loading branch information
ccordoba12 committed Dec 7, 2023
1 parent 8a1abd1 commit 4b9958f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
10 changes: 7 additions & 3 deletions spyder/api/widgets/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
self.setMinimumWidth(min_width)

# Signals
self.aboutToShow.connect(self._render)
self.aboutToShow.connect(self.render)

# Adjustmens for Mac
if sys.platform == 'darwin':
Expand Down Expand Up @@ -267,7 +267,7 @@ def _add_missing_actions(self):

self._unintroduced_actions = {}

def _render(self):
def render(self):
"""
Create the menu prior to showing it. This takes into account sections
and location of menus.
Expand All @@ -278,6 +278,8 @@ def _render(self):

actions = self.get_actions()
add_actions(self, actions)
self._set_icons()

self._dirty = False

def _add_section(self, section, before_section=None):
Expand Down Expand Up @@ -440,7 +442,7 @@ class PluginMainWidgetOptionsMenu(SpyderMenu):
Options menu for PluginMainWidget.
"""

def _render(self):
def render(self):
"""Render the menu's bottom section as expected."""
if self._dirty:
self.clear()
Expand All @@ -461,4 +463,6 @@ def _render(self):
actions.append(action)

add_actions(self, actions)
self._set_icons()

self._dirty = False
2 changes: 1 addition & 1 deletion spyder/plugins/application/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def create_debug_log_actions(self):
)

# Render menu
self.menu_debug_logs._render()
self.menu_debug_logs.render()

def load_log_file(self, file):
"""Load log file in editor"""
Expand Down
3 changes: 1 addition & 2 deletions spyder/plugins/ipythonconsole/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,7 @@ def update_environment_menu(self):
menu=self.console_environment_menu
)

self.console_environment_menu._render()
self.console_environment_menu._set_icons()
self.console_environment_menu.render()

# ---- GUI options
@on_conf_change(section='help', option='connect/ipython_console')
Expand Down
7 changes: 3 additions & 4 deletions spyder/plugins/mainmenu/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ def on_initialize(self):
create_app_menu(ApplicationMenus.Help, _("&Help"))

def on_mainwindow_visible(self):
# Pre-render menus so actions with menu roles (like "About Spyder"
# and "Preferences") are located in the right place in Mac's menu
# bar.
# Pre-render menus so actions with menu roles (like "About Spyder" and
# "Preferences") are located in the right place in Mac's menu bar.
# Fixes spyder-ide/spyder#14917
# This also registers shortcuts for actions that are only in menus.
# Fixes spyder-ide/spyder#16061
for menu in self._APPLICATION_MENUS.values():
menu._render()
menu.render()

# ---- Private methods
# ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/projects/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def _setup_menu_actions(self):
section=RecentProjectsMenuSections.Extras)

self._update_project_actions()
self.recent_project_menu._render()
self.recent_project_menu.render()

def _build_opener(self, project):
"""Build function opening passed project"""
Expand Down
4 changes: 2 additions & 2 deletions spyder/utils/qthelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,10 @@ def set_menu_icons(menu, state, in_app_menu=False):
for action in menu_actions:
try:
if action.menu() is not None:
# This is necessary to decide if show icons or not
# This is necessary to decide if we need to show icons or not
action.menu()._in_app_menu = in_app_menu

# This is submenu, so we need to call this again
# This is a submenu, so we need to call this again
set_menu_icons(action.menu(), state, in_app_menu)
elif action.isSeparator():
continue
Expand Down

0 comments on commit 4b9958f

Please sign in to comment.