now let' define some invoker classes these will model toolbarmenuand keyboard events that can happenagainthey aren' actually hooked up to anythingbut we can see how they are decoupled from the commandreceiverand client codeclass toolbarbuttondef __init__(selfnameiconname)self name name self iconname iconname def click(self)self command execute(class menuitemdef __init__(selfmenu_namemenuitem_name)self menu menu_name self item menuitem_name def click(self)self command execute(class keyboardshortcutdef __init__(selfkeymodifier)self key key self modifier modifier def keypress(self)self command execute(notice how the various action methods each call the execute method on their respective commandsthis code doesn' show the command attribute being set on each object they could be passed into the __init__ functionbut because they may be changed (for examplewith customizable keybinding editor)it makes more sense to set the attributes on the objects afterwards nowlet' hook up the commands themselvesclass savecommanddef __init__(selfdocument)self document document def execute(self)self document save(class exitcommand