'Add appropriate entries to the menus and submenus
Menus that are absent or None in self.menudict are ignored.'

def fill_menus(self, menudefs=None, keydefs=None):

    if (menudefs is None):
        menudefs = self.Bindings.menudefs
    if (keydefs is None):
        keydefs = self.Bindings.default_keydefs
    menudict = self.menudict
    text = self.text
    for (mname, entrylist) in menudefs:
        menu = menudict.get(mname)
        if (not menu):
            continue
        for entry in entrylist:
            if (not entry):
                menu.add_separator()
            else:
                (label, eventname) = entry
                checkbutton = (label[:1] == '!')
                if checkbutton:
                    label = label[1:]
                (underline, label) = prepstr(label)
                accelerator = get_accelerator(keydefs, eventname)
                def command(text=text, eventname=eventname):
                    text.event_generate(eventname)
                if checkbutton:
                    var = self.get_var_obj(eventname, BooleanVar)
                    menu.add_checkbutton(label=label, underline=underline, command=command, accelerator=accelerator, variable=var)
                else:
                    menu.add_command(label=label, underline=underline, command=command, accelerator=accelerator)
