MCPcopy Index your code
hub / github.com/python/cpython / createmenubar

Method createmenubar

Lib/idlelib/editor.py:430–465  ·  view source on GitHub ↗

Populate the menu bar widget for the editor window. Each option on the menubar is itself a cascade-type Menu widget with the menubar as the parent. The names, labels, and menu shortcuts for the menubar items are stored in menu_specs. Each submenu is subsequently po

(self)

Source from the content-addressed store, hash-verified

428 ]
429
430 def createmenubar(self):
431 """Populate the menu bar widget for the editor window.
432
433 Each option on the menubar is itself a cascade-type Menu widget
434 with the menubar as the parent. The names, labels, and menu
435 shortcuts for the menubar items are stored in menu_specs. Each
436 submenu is subsequently populated in fill_menus(), except for
437 'Recent Files' which is added to the File menu here.
438
439 Instance variables:
440 menubar: Menu widget containing first level menu items.
441 menudict: Dictionary of {menuname: Menu instance} items. The keys
442 represent the valid menu items for this window and may be a
443 subset of all the menudefs available.
444 recent_files_menu: Menu widget contained within the 'file' menudict.
445 """
446 mbar = self.menubar
447 self.menudict = menudict = {}
448 for name, label in self.menu_specs:
449 underline, label = prepstr(label)
450 postcommand = getattr(self, f'{name}_menu_postcommand', None)
451 menudict[name] = menu = Menu(mbar, name=name, tearoff=0,
452 postcommand=postcommand)
453 mbar.add_cascade(label=label, menu=menu, underline=underline)
454 if macosx.isCarbonTk():
455 # Insert the application menu
456 menudict['application'] = menu = Menu(mbar, name='apple',
457 tearoff=0)
458 mbar.add_cascade(label='IDLE', menu=menu)
459 self.fill_menus()
460 self.recent_files_menu = Menu(self.menubar, tearoff=0)
461 self.menudict['file'].insert_cascade(3, label='Recent Files',
462 underline=0,
463 menu=self.recent_files_menu)
464 self.base_helpmenu_length = self.menudict['help'].index(END)
465 self.reset_help_menu_entries()
466
467 def postwindowsmenu(self):
468 """Callback to register window.

Callers 1

__init__Method · 0.95

Calls 7

fill_menusMethod · 0.95
prepstrFunction · 0.85
MenuClass · 0.85
add_cascadeMethod · 0.80
insert_cascadeMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected