diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index dff104ff0f1..cba34bf8f6b 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -449,7 +449,9 @@ class EditorWindow(object): self.menudict = menudict = {} for name, label in self.menu_specs: underline, label = prepstr(label) - menudict[name] = menu = Menu(mbar, name=name, tearoff=0) + postcommand = getattr(self, f'{name}_menu_postcommand', None) + menudict[name] = menu = Menu(mbar, name=name, tearoff=0, + postcommand=postcommand) mbar.add_cascade(label=label, menu=menu, underline=underline) if macosx.isCarbonTk(): # Insert the application menu diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 065122dec7a..d8d67e7d9bf 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -990,6 +990,10 @@ class PyShell(OutputWindow): self.showprompt() self.set_debugger_indicator() + def debug_menu_postcommand(self): + state = 'disabled' if self.executing else 'normal' + self.update_menu_state('debug', '*Stack Viewer', state) + def beginexecuting(self): "Helper for ModifiedInterpreter" self.resetoutput() diff --git a/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst b/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst new file mode 100644 index 00000000000..aa6b504a793 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-11-14-23-41-07.bpo-23544.3etemb.rst @@ -0,0 +1,2 @@ +The "Stack Viewer" item in the "Debug" menu can no longer be selected when +user code is running.