Coverage for mainmenu.py: 69%

9 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-11 13:22 -0700

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 ('Module _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 Window', '<<close-window>>'), 

38 ('E_xit IDLE', '<<close-all-windows>>'), 

39 ]), 

40 

41 ('edit', [ 

42 ('_Undo', '<<undo>>'), 

43 ('_Redo', '<<redo>>'), 

44 None, 

45 ('Select _All', '<<select-all>>'), 

46 ('Cu_t', '<<cut>>'), 

47 ('_Copy', '<<copy>>'), 

48 ('_Paste', '<<paste>>'), 

49 None, 

50 ('_Find...', '<<find>>'), 

51 ('Find A_gain', '<<find-again>>'), 

52 ('Find _Selection', '<<find-selection>>'), 

53 ('Find in Files...', '<<find-in-files>>'), 

54 ('R_eplace...', '<<replace>>'), 

55 None, 

56 ('Go to _Line', '<<goto-line>>'), 

57 ('S_how Completions', '<<force-open-completions>>'), 

58 ('E_xpand Word', '<<expand-word>>'), 

59 ('Show C_all Tip', '<<force-open-calltip>>'), 

60 ('Show Surrounding P_arens', '<<flash-paren>>'), 

61 ]), 

62 

63 ('format', [ 

64 ('F_ormat Paragraph', '<<format-paragraph>>'), 

65 ('_Indent Region', '<<indent-region>>'), 

66 ('_Dedent Region', '<<dedent-region>>'), 

67 ('Comment _Out Region', '<<comment-region>>'), 

68 ('U_ncomment Region', '<<uncomment-region>>'), 

69 ('Tabify Region', '<<tabify-region>>'), 

70 ('Untabify Region', '<<untabify-region>>'), 

71 ('Toggle Tabs', '<<toggle-tabs>>'), 

72 ('New Indent Width', '<<change-indentwidth>>'), 

73 ('S_trip Trailing Whitespace', '<<do-rstrip>>'), 

74 ]), 

75 

76 ('run', [ 

77 ('R_un Module', '<<run-module>>'), 

78 ('Run... _Customized', '<<run-custom>>'), 

79 ('C_heck Module', '<<check-module>>'), 

80 ('Python Shell', '<<open-python-shell>>'), 

81 ]), 

82 

83 ('shell', [ 

84 ('_View Last Restart', '<<view-restart>>'), 

85 ('_Restart Shell', '<<restart-shell>>'), 

86 None, 

87 ('_Previous History', '<<history-previous>>'), 

88 ('_Next History', '<<history-next>>'), 

89 None, 

90 ('_Interrupt Execution', '<<interrupt-execution>>'), 

91 ]), 

92 

93 ('debug', [ 

94 ('_Go to File/Line', '<<goto-file-line>>'), 

95 ('!_Debugger', '<<toggle-debugger>>'), 

96 ('_Stack Viewer', '<<open-stack-viewer>>'), 

97 ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'), 

98 ]), 

99 

100 ('options', [ 

101 ('Configure _IDLE', '<<open-config-dialog>>'), 

102 None, 

103 ('Show _Code Context', '<<toggle-code-context>>'), 

104 ('Show _Line Numbers', '<<toggle-line-numbers>>'), 

105 ('Show _Code Outline', '<<show-code-outline>>'), 

106 ('_Zoom Height', '<<zoom-height>>'), 

107 ]), 

108 

109 ('window', [ 

110 ]), 

111 

112 ('help', [ 

113 ('_About IDLE', '<<about-idle>>'), 

114 None, 

115 ('_IDLE Doc', '<<help>>'), 

116 ('Python _Docs', '<<python-docs>>'), 

117 ]), 

118] 

119 

120if find_spec('turtledemo'): 120 ↛ 123line 120 didn't jump to line 123, because the condition on line 120 was never false

121 menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>')) 

122 

123default_keydefs = idleConf.GetCurrentKeySet() 

124 

125if __name__ == '__main__': 125 ↛ 126line 125 didn't jump to line 126, because the condition on line 125 was never true

126 from unittest import main 

127 main('idlelib.idle_test.test_mainmenu', verbosity=2)