Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk.
(root, flist)
| 139 | pass |
| 140 | |
| 141 | def overrideRootMenu(root, flist): |
| 142 | """ |
| 143 | Replace the Tk root menu by something that is more appropriate for |
| 144 | IDLE with an Aqua Tk. |
| 145 | """ |
| 146 | # The menu that is attached to the Tk root (".") is also used by AquaTk for |
| 147 | # all windows that don't specify a menu of their own. The default menubar |
| 148 | # contains a number of menus, none of which are appropriate for IDLE. The |
| 149 | # Most annoying of those is an 'About Tck/Tk...' menu in the application |
| 150 | # menu. |
| 151 | # |
| 152 | # This function replaces the default menubar by a mostly empty one, it |
| 153 | # should only contain the correct application menu and the window menu. |
| 154 | # |
| 155 | # Due to a (mis-)feature of TkAqua the user will also see an empty Help |
| 156 | # menu. |
| 157 | from tkinter import Menu |
| 158 | from idlelib import mainmenu |
| 159 | from idlelib import window |
| 160 | |
| 161 | closeItem = mainmenu.menudefs[0][1][-2] |
| 162 | |
| 163 | # Remove the last 3 items of the file menu: a separator, close window and |
| 164 | # quit. Close window will be reinserted just above the save item, where |
| 165 | # it should be according to the HIG. Quit is in the application menu. |
| 166 | del mainmenu.menudefs[0][1][-3:] |
| 167 | mainmenu.menudefs[0][1].insert(6, closeItem) |
| 168 | |
| 169 | # Remove the 'About' entry from the help menu, it is in the application |
| 170 | # menu |
| 171 | del mainmenu.menudefs[-1][1][0:2] |
| 172 | # Remove the 'Configure Idle' entry from the options menu, it is in the |
| 173 | # application menu as 'Preferences' |
| 174 | del mainmenu.menudefs[-3][1][0:2] |
| 175 | menubar = Menu(root) |
| 176 | root.configure(menu=menubar) |
| 177 | |
| 178 | menu = Menu(menubar, name='window', tearoff=0) |
| 179 | menubar.add_cascade(label='Window', menu=menu, underline=0) |
| 180 | |
| 181 | def postwindowsmenu(menu=menu): |
| 182 | end = menu.index('end') |
| 183 | if end is None: |
| 184 | end = -1 |
| 185 | |
| 186 | if end > 0: |
| 187 | menu.delete(0, end) |
| 188 | window.add_windows_to_menu(menu) |
| 189 | window.register_callback(postwindowsmenu) |
| 190 | |
| 191 | def about_dialog(event=None): |
| 192 | "Handle Help 'About IDLE' event." |
| 193 | # Synchronize with editor.EditorWindow.about_dialog. |
| 194 | from idlelib import help_about |
| 195 | help_about.AboutDialog(root) |
| 196 | |
| 197 | def config_dialog(event=None): |
| 198 | "Handle Options 'Configure IDLE' event." |
no test coverage detected
searching dependent graphs…