jpayne@68: """Define the menu contents, hotkeys, and event bindings. jpayne@68: jpayne@68: There is additional configuration information in the EditorWindow class (and jpayne@68: subclasses): the menus are created there based on the menu_specs (class) jpayne@68: variable, and menus not created are silently skipped in the code here. This jpayne@68: makes it possible, for example, to define a Debug menu which is only present in jpayne@68: the PythonShell window, and a Format menu which is only present in the Editor jpayne@68: windows. jpayne@68: jpayne@68: """ jpayne@68: from importlib.util import find_spec jpayne@68: jpayne@68: from idlelib.config import idleConf jpayne@68: jpayne@68: # Warning: menudefs is altered in macosx.overrideRootMenu() jpayne@68: # after it is determined that an OS X Aqua Tk is in use, jpayne@68: # which cannot be done until after Tk() is first called. jpayne@68: # Do not alter the 'file', 'options', or 'help' cascades here jpayne@68: # without altering overrideRootMenu() as well. jpayne@68: # TODO: Make this more robust jpayne@68: jpayne@68: menudefs = [ jpayne@68: # underscore prefixes character to underscore jpayne@68: ('file', [ jpayne@68: ('_New File', '<>'), jpayne@68: ('_Open...', '<>'), jpayne@68: ('Open _Module...', '<>'), jpayne@68: ('Module _Browser', '<>'), jpayne@68: ('_Path Browser', '<>'), jpayne@68: None, jpayne@68: ('_Save', '<>'), jpayne@68: ('Save _As...', '<>'), jpayne@68: ('Save Cop_y As...', '<>'), jpayne@68: None, jpayne@68: ('Prin_t Window', '<>'), jpayne@68: None, jpayne@68: ('_Close', '<>'), jpayne@68: ('E_xit', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('edit', [ jpayne@68: ('_Undo', '<>'), jpayne@68: ('_Redo', '<>'), jpayne@68: None, jpayne@68: ('Cu_t', '<>'), jpayne@68: ('_Copy', '<>'), jpayne@68: ('_Paste', '<>'), jpayne@68: ('Select _All', '<>'), jpayne@68: None, jpayne@68: ('_Find...', '<>'), jpayne@68: ('Find A_gain', '<>'), jpayne@68: ('Find _Selection', '<>'), jpayne@68: ('Find in Files...', '<>'), jpayne@68: ('R_eplace...', '<>'), jpayne@68: ('Go to _Line', '<>'), jpayne@68: ('S_how Completions', '<>'), jpayne@68: ('E_xpand Word', '<>'), jpayne@68: ('Show C_all Tip', '<>'), jpayne@68: ('Show Surrounding P_arens', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('format', [ jpayne@68: ('F_ormat Paragraph', '<>'), jpayne@68: ('_Indent Region', '<>'), jpayne@68: ('_Dedent Region', '<>'), jpayne@68: ('Comment _Out Region', '<>'), jpayne@68: ('U_ncomment Region', '<>'), jpayne@68: ('Tabify Region', '<>'), jpayne@68: ('Untabify Region', '<>'), jpayne@68: ('Toggle Tabs', '<>'), jpayne@68: ('New Indent Width', '<>'), jpayne@68: ('S_trip Trailing Whitespace', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('run', [ jpayne@68: ('R_un Module', '<>'), jpayne@68: ('Run... _Customized', '<>'), jpayne@68: ('C_heck Module', '<>'), jpayne@68: ('Python Shell', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('shell', [ jpayne@68: ('_View Last Restart', '<>'), jpayne@68: ('_Restart Shell', '<>'), jpayne@68: None, jpayne@68: ('_Previous History', '<>'), jpayne@68: ('_Next History', '<>'), jpayne@68: None, jpayne@68: ('_Interrupt Execution', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('debug', [ jpayne@68: ('_Go to File/Line', '<>'), jpayne@68: ('!_Debugger', '<>'), jpayne@68: ('_Stack Viewer', '<>'), jpayne@68: ('!_Auto-open Stack Viewer', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('options', [ jpayne@68: ('Configure _IDLE', '<>'), jpayne@68: None, jpayne@68: ('Show _Code Context', '<>'), jpayne@68: ('Show _Line Numbers', '<>'), jpayne@68: ('_Zoom Height', '<>'), jpayne@68: ]), jpayne@68: jpayne@68: ('window', [ jpayne@68: ]), jpayne@68: jpayne@68: ('help', [ jpayne@68: ('_About IDLE', '<>'), jpayne@68: None, jpayne@68: ('_IDLE Help', '<>'), jpayne@68: ('Python _Docs', '<>'), jpayne@68: ]), jpayne@68: ] jpayne@68: jpayne@68: if find_spec('turtledemo'): jpayne@68: menudefs[-1][1].append(('Turtle Demo', '<>')) jpayne@68: jpayne@68: default_keydefs = idleConf.GetCurrentKeySet() jpayne@68: jpayne@68: if __name__ == '__main__': jpayne@68: from unittest import main jpayne@68: main('idlelib.idle_test.test_mainmenu', verbosity=2)