(self, menu_id, _menu_options=None, **kwargs)
Change a menu item where the ID matches the input.
Change a menu item where the ID matches the input.
Change a menu item where the ID matches the input .
def set_menu_item(self, menu_id, _menu_options=None, **kwargs):
        """Change a menu item where the ID matches the input."""
        if _menu_options is None:
            menu_options = self._menu_options
        else:
            menu_options = _menu_options
        
        for i, menu_option in enumerate(menu_options):
            #Get ID value, or skip if no ID
            id = menu_option.get('id', None)
            if id is None:
                continue
            
            #Update value if correct ID
            if id == menu_id:
                for k, v in iteritems(kwargs):
                    menu_options[i][k] = v
                self.logger.debug('Menu item "%s" updated (%s).', id, ', '.join('{}:"{}"'.format(k, v) for k, v in iteritems(kwargs)))
            
            #Look in submenu
            else:
                action = menu_option.get('action', None)
                if isinstance(action, tuple):
                    self.set_menu_item(menu_id, _menu_options=action, **kwargs)
        
        if _menu_options is None:
            self._refresh_menu(menu_options)
def set_menu_item ( self , menu_id , _menu_options = None , * * kwargs ) : if _menu_options is None : menu_options = self . _menu_options else : menu_options = _menu_options for i , menu_option in enumerate ( menu_options ) : #Get ID value, or skip if no ID id = menu_option . get ( 'id' , None ) if id is None : continue #Update value if correct ID if id == menu_id : for k , v in iteritems ( kwargs ) : menu_options [ i ] [ k ] = v self . logger . debug ( 'Menu item "%s" updated (%s).' , id , ', ' . join ( '{}:"{}"' . format ( k , v ) for k , v in iteritems ( kwargs ) ) ) #Look in submenu else : action = menu_option . get ( 'action' , None ) if isinstance ( action , tuple ) : self . set_menu_item ( menu_id , _menu_options = action , * * kwargs ) if _menu_options is None : self . _refresh_menu ( menu_options )