def addAcceleratorCommand(acceleratorBinding, commandFunction, master, menu, text):
 acceleratorText = acceleratorBinding[1:(-1)]
 lastIndexOfMinus = acceleratorText.rfind('-')
 if (lastIndexOfMinus > (-1)):
  acceleratorText = (acceleratorText[:(lastIndexOfMinus + 1)] + acceleratorText[(lastIndexOfMinus + 1):].capitalize())
 acceleratorText = acceleratorText.replace('KeyPress-', '')
 acceleratorText = acceleratorText.replace('-', '+')
 acceleratorText = acceleratorText.replace('Control', 'Ctrl')
 acceleratorBinding = acceleratorBinding.replace('KeyPress', '')
 menu.add_command(accelerator=acceleratorText, label=text, underline=0, command=commandFunction)
 master.bind(acceleratorBinding, commandFunction)

def addAcceleratorCommand ( acceleratorBinding , commandFunction , master , menu , text ) : acceleratorText = acceleratorBinding [ 1 : ( - 1 ) ] lastIndexOfMinus = acceleratorText . rfind ( '-' ) if ( lastIndexOfMinus > ( - 1 ) ) : acceleratorText = ( acceleratorText [ : ( lastIndexOfMinus + 1 ) ] + acceleratorText [ ( lastIndexOfMinus + 1 ) : ] . capitalize ( ) ) acceleratorText = acceleratorText . replace ( 'KeyPress-' , '' ) acceleratorText = acceleratorText . replace ( '-' , '+' ) acceleratorText = acceleratorText . replace ( 'Control' , 'Ctrl' ) acceleratorBinding = acceleratorBinding . replace ( 'KeyPress' , '' ) menu . add_command ( accelerator = acceleratorText , label = text , underline = 0 , command = commandFunction ) master . bind ( acceleratorBinding , commandFunction )
add accelerator command .