def terminate() pygame quit( sys exit( def checkforquit() for event in pygame event get(quit)get all the quit events terminate(terminate if any quit events are present for event in pygame event get(keyup)get all the keyup events if event key =k_escape terminate(terminate if the keyup event was for the esc key pygame event post(eventput the other keyup event objects back def flashbuttonanimation(coloranimationspeed= ) if color =yellow sound beep flashcolor brightyellow rectangle yellowrect elif color =blue sound beep flashcolor brightblue rectangle bluerect elif color =red sound beep flashcolor brightred rectangle redrect elif color =green sound beep flashcolor brightgreen rectangle greenrect origsurf displaysurf copy( flashsurf pygame surface((buttonsizebuttonsize) flashsurf flashsurf convert_alpha( rgb flashcolor sound play( for startendstep in (( )( - ))animation loop for alpha in range(startendanimationspeed step) checkforquit( displaysurf blit(origsurf( ) flashsurf fill((rgbalpha) displaysurf blit(flashsurfrectangle topleft pygame display update( fpsclock tick(fpsemail questions to the authoral@inventwithpython com