(*args)
return decorator
Decorator for registering a function as a callback for a click action. MenuItem class deals with delegating the
    event to the callback function, passed here to set_callback method.
Decorator for registering a function as a callback for a click action. MenuItem class deals with delegating the
    event to the callback function, passed here to set_callback method.
Decorator for registering a function as a callback for a click action . MenuItem class deals with delegating the event to the callback function passed here to set_callback method .
def clicked(*args):
    """
    Decorator for registering a function as a callback for a click action. MenuItem class deals with delegating the
    event to the callback function, passed here to set_callback method.
    """
    def decorator(f):

        def register_click(self):
            menuitem = self._menu  # self not defined yet but will be later in 'run' method
            if menuitem is None:
                raise ValueError('no menu created')
            try:
                for arg in args:
                    menuitem = menuitem[arg]
            except KeyError:
                raise ValueError('no path exists in menu for {}'.format(' -> '.join(map(repr, args))))
            menuitem.set_callback(f)

        # delay registering the button until we have a current instance to be able to traverse the menu
        buttons = clicked.__dict__.setdefault('*buttons', [])
        buttons.append(register_click)

        return f
    return decorator
def clicked ( * args ) : def decorator ( f ) : def register_click ( self ) : menuitem = self . _menu # self not defined yet but will be later in 'run' method if menuitem is None : raise ValueError ( 'no menu created' ) try : for arg in args : menuitem = menuitem [ arg ] except KeyError : raise ValueError ( 'no path exists in menu for {}' . format ( ' -> ' . join ( map ( repr , args ) ) ) ) menuitem . set_callback ( f ) # delay registering the button until we have a current instance to be able to traverse the menu buttons = clicked . __dict__ . setdefault ( '*buttons' , [ ] ) buttons . append ( register_click ) return f return decorator