Skip to content

Commit

Permalink
IDLE: Create function to update menu item state. (pythonGH-11343)
Browse files Browse the repository at this point in the history
This will be needed for other menu items.  Change outwin to call the function instead of updating the menu item directly.
  • Loading branch information
csabella authored and terryjreedy committed Dec 28, 2018
1 parent 9e00d9e commit 804a5d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,15 @@ def postwindowsmenu(self):
window.add_windows_to_menu(menu)

def update_menu_label(self, menu, index, label):
"Update label for menu item at index ."
"Update label for menu item at index."
menuitem = self.menudict[menu]
menuitem.entryconfig(index, label=label)

def update_menu_state(self, menu, index, state):
"Update state for menu item at index."
menuitem = self.menudict[menu]
menuitem.entryconfig(index, state=state)

def handle_yview(self, event, *args):
"Handle scrollbar."
if event == 'moveto':
Expand Down
3 changes: 1 addition & 2 deletions Lib/idlelib/outwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def __init__(self, *args):
EditorWindow.__init__(self, *args)
self.text.bind("<<goto-file-line>>", self.goto_file_line)
self.text.unbind("<<toggle-code-context>>")
self.menudict['options'].entryconfig('*Code Context',
state='disabled')
self.update_menu_state('options', '*Code Context', 'disabled')

# Customize EditorWindow
def ispythonsource(self, filename):
Expand Down

0 comments on commit 804a5d9

Please sign in to comment.