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