From 8c6e4bd8463113896f2b970d80d87a68fd080518 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Mon, 13 Nov 2023 09:07:30 -0500 Subject: [PATCH] IPython console: Unify all its menus under a single enum - That enum is IPythonConsoleWidgetMenus. - That's because several menus are placed in different places, not only in the console options menu. --- spyder/plugins/ipythonconsole/api.py | 9 +++------ spyder/plugins/ipythonconsole/plugin.py | 10 +++++++--- .../plugins/ipythonconsole/widgets/main_widget.py | 15 +++++++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/spyder/plugins/ipythonconsole/api.py b/spyder/plugins/ipythonconsole/api.py index 6982c64b20a..691d838353c 100644 --- a/spyder/plugins/ipythonconsole/api.py +++ b/spyder/plugins/ipythonconsole/api.py @@ -69,10 +69,12 @@ class IPythonConsoleWidgetActions: QuickReference = 'quick reference' -class IPythonConsoleWidgetOptionsMenus: +class IPythonConsoleWidgetMenus: SpecialConsoles = 'special_consoles_submenu' Documentation = 'documentation_submenu' EnvironmentConsoles = 'environment_consoles_submenu' + ClientContextMenu = 'client_context_menu' + TabsContextMenu = 'tabs_context_menu' class IPythonConsoleWidgetOptionsMenuSections: @@ -80,11 +82,6 @@ class IPythonConsoleWidgetOptionsMenuSections: View = 'view_section' -class IPythonConsoleWidgetMenus: - ClientContextMenu = 'client_context_menu' - TabsContextMenu = 'tabs_context_menu' - - class IPythonConsoleWidgetTabsContextMenuSections: Consoles = 'tabs_consoles_section' Edit = 'tabs_edit_section' diff --git a/spyder/plugins/ipythonconsole/plugin.py b/spyder/plugins/ipythonconsole/plugin.py index 346c7d2f485..6f3f66c6e76 100644 --- a/spyder/plugins/ipythonconsole/plugin.py +++ b/spyder/plugins/ipythonconsole/plugin.py @@ -21,11 +21,15 @@ from spyder.api.plugin_registration.decorators import ( on_plugin_available, on_plugin_teardown) from spyder.api.translations import _ -from spyder.plugins.ipythonconsole.api import IPythonConsolePyConfiguration +from spyder.plugins.ipythonconsole.api import ( + IPythonConsolePyConfiguration, + IPythonConsoleWidgetMenus +) from spyder.plugins.ipythonconsole.confpage import IPythonConsoleConfigPage from spyder.plugins.ipythonconsole.widgets.config import IPythonConfigOptions from spyder.plugins.ipythonconsole.widgets.main_widget import ( - IPythonConsoleWidget, IPythonConsoleWidgetOptionsMenus) + IPythonConsoleWidget +) from spyder.plugins.mainmenu.api import ( ApplicationMenus, ConsolesMenuSections, HelpMenuSections) from spyder.plugins.run.api import ( @@ -424,7 +428,7 @@ def on_main_menu_teardown(self): # IPython documentation menu mainmenu.remove_item_from_application_menu( - IPythonConsoleWidgetOptionsMenus.Documentation, + IPythonConsoleWidgetMenus.Documentation, menu_id=ApplicationMenus.Help ) diff --git a/spyder/plugins/ipythonconsole/widgets/main_widget.py b/spyder/plugins/ipythonconsole/widgets/main_widget.py index 26551e48f8c..4291464ab0a 100644 --- a/spyder/plugins/ipythonconsole/widgets/main_widget.py +++ b/spyder/plugins/ipythonconsole/widgets/main_widget.py @@ -34,9 +34,12 @@ from spyder.api.widgets.main_widget import PluginMainWidget from spyder.config.base import get_home_dir, running_under_pytest from spyder.plugins.ipythonconsole.api import ( - IPythonConsoleWidgetActions, IPythonConsoleWidgetMenus, - IPythonConsoleWidgetOptionsMenus, IPythonConsoleWidgetOptionsMenuSections, - IPythonConsoleWidgetTabsContextMenuSections, ClientContextMenuActions) + ClientContextMenuActions, + IPythonConsoleWidgetActions, + IPythonConsoleWidgetMenus, + IPythonConsoleWidgetOptionsMenuSections, + IPythonConsoleWidgetTabsContextMenuSections +) from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec from spyder.plugins.ipythonconsole.utils.style import create_qss_style @@ -543,7 +546,7 @@ def setup(self): options_menu = self.get_options_menu() self.console_environment_menu = self.create_menu( - IPythonConsoleWidgetOptionsMenus.EnvironmentConsoles, + IPythonConsoleWidgetMenus.EnvironmentConsoles, _('New console in environment') ) stylesheet = qstylizer.style.StyleSheet() @@ -551,7 +554,7 @@ def setup(self): self.console_environment_menu.setStyleSheet(stylesheet.toString()) self.special_console_menu = self.create_menu( - IPythonConsoleWidgetOptionsMenus.SpecialConsoles, + IPythonConsoleWidgetMenus.SpecialConsoles, _('New special console')) for item in [ @@ -658,7 +661,7 @@ def setup(self): # --- Create IPython documentation menu self.ipython_menu = self.create_menu( - menu_id=IPythonConsoleWidgetOptionsMenus.Documentation, + menu_id=IPythonConsoleWidgetMenus.Documentation, title=_("IPython documentation")) intro_action = self.create_action( IPythonConsoleWidgetActions.IPythonDocumentation,