def _bind_traversal( self, w ) :
        """Internal routine to bind arrow keys and focus for menu
        traversal"""
        self._add_binding( w, '<FocusIn>', self._do_focus_in, '+' )
        self._add_binding( w, '<Up>', self._menu_traverse, '+' )
        self._add_binding( w, '<Down>', self._menu_traverse, '+' )
        self._add_binding( w, '<Escape>', self._close_event, '+' )
        try :
            ul = w.cget( 'underline' )
            txt = w.cget( 'text' ).lower()
            if ul is not None and  ul >=  0 and txt is not None :
                self._add_binding(
                    root, "<Alt-%s>" % (txt[ ul ] ),
                    lambda e, w = w : self._do_hotkey( w, e ), '+' )
        except :
            pass

        # if we're a child menu, allow arrow keys to move back from
        # child to parent
        if self._is_submenu :
            if self._cascade_side == RIGHT :
                self._add_binding( w, '<Left>', self._activate_top, '+' )
            else :
                self._add_binding( w, '<Right>', self._activate_top, '+' )
Internal routine to bind arrow keys and focus for menu
        traversal
recipes/Python/442500_ExtraMenu__TkInter_menu_arbitrary_widgets/recipe-442500.py