1"""Define the menu contents, hotkeys, and event bindings. 2 3There is additional configuration information in the EditorWindow class (and 4subclasses): the menus are created there based on the menu_specs (class) 5variable, and menus not created are silently skipped in the code here. This 6makes it possible, for example, to define a Debug menu which is only present in 7the PythonShell window, and a Format menu which is only present in the Editor 8windows. 9 10""" 11from importlib.util import find_spec 12 13from idlelib.config import idleConf 14 15# Warning: menudefs is altered in macosx.overrideRootMenu() 16# after it is determined that an OS X Aqua Tk is in use, 17# which cannot be done until after Tk() is first called. 18# Do not alter the 'file', 'options', or 'help' cascades here 19# without altering overrideRootMenu() as well. 20# TODO: Make this more robust 21 22menudefs = [ 23 # underscore prefixes character to underscore 24 ('file', [ 25 ('_New File', '<<open-new-window>>'), 26 ('_Open...', '<<open-window-from-file>>'), 27 ('Open _Module...', '<<open-module>>'), 28 ('Class _Browser', '<<open-class-browser>>'), 29 ('_Path Browser', '<<open-path-browser>>'), 30 None, 31 ('_Save', '<<save-window>>'), 32 ('Save _As...', '<<save-window-as-file>>'), 33 ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'), 34 None, 35 ('Prin_t Window', '<<print-window>>'), 36 None, 37 ('_Close', '<<close-window>>'), 38 ('E_xit', '<<close-all-windows>>'), 39 ]), 40 ('edit', [ 41 ('_Undo', '<<undo>>'), 42 ('_Redo', '<<redo>>'), 43 None, 44 ('Cu_t', '<<cut>>'), 45 ('_Copy', '<<copy>>'), 46 ('_Paste', '<<paste>>'), 47 ('Select _All', '<<select-all>>'), 48 None, 49 ('_Find...', '<<find>>'), 50 ('Find A_gain', '<<find-again>>'), 51 ('Find _Selection', '<<find-selection>>'), 52 ('Find in Files...', '<<find-in-files>>'), 53 ('R_eplace...', '<<replace>>'), 54 ('Go to _Line', '<<goto-line>>'), 55 ]), 56('format', [ 57 ('_Indent Region', '<<indent-region>>'), 58 ('_Dedent Region', '<<dedent-region>>'), 59 ('Comment _Out Region', '<<comment-region>>'), 60 ('U_ncomment Region', '<<uncomment-region>>'), 61 ('Tabify Region', '<<tabify-region>>'), 62 ('Untabify Region', '<<untabify-region>>'), 63 ('Toggle Tabs', '<<toggle-tabs>>'), 64 ('New Indent Width', '<<change-indentwidth>>'), 65 ]), 66 ('run', [ 67 ('Python Shell', '<<open-python-shell>>'), 68 ]), 69 ('shell', [ 70 ('_View Last Restart', '<<view-restart>>'), 71 ('_Restart Shell', '<<restart-shell>>'), 72 None, 73 ('_Interrupt Execution', '<<interrupt-execution>>'), 74 ]), 75 ('debug', [ 76 ('_Go to File/Line', '<<goto-file-line>>'), 77 ('!_Debugger', '<<toggle-debugger>>'), 78 ('_Stack Viewer', '<<open-stack-viewer>>'), 79 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'), 80 ]), 81 ('options', [ 82 ('Configure _IDLE', '<<open-config-dialog>>'), 83 None, 84 ]), 85 ('help', [ 86 ('_About IDLE', '<<about-idle>>'), 87 None, 88 ('_IDLE Help', '<<help>>'), 89 ('Python _Docs', '<<python-docs>>'), 90 ]), 91] 92 93if find_spec('turtledemo'): 94 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>')) 95 96default_keydefs = idleConf.GetCurrentKeySet() 97