displaysurf blit(flashsurfrectangle topleftpygame display update(fpsclock tick(fpsdisplaysurf blit(origsurf( )we check for any quit events (in case the user tried to close the program during the animation)then blit the origsurf surface to the display surface then we paint the flashsurf surface by calling fill((supplying the rgb values of the color we got on line and the alpha value that the for loop sets in the alpha variablethen the flashsurf surface is blitted to the display surface thento make the display surface appear on the screenpygame display update(is called on line to make sure the animation doesn' play as fast as the computer can draw itwe add short pauses with call to the tick(method (if you want to see the flashing animation play very slowlyput low number like or as the argument to tick(instead of fps drawing the buttons def drawbuttons() pygame draw rect(displaysurfyellowyellowrect pygame draw rect(displaysurfbluebluerect pygame draw rect(displaysurfredredrect pygame draw rect(displaysurfgreengreenrectsince each of the buttons is just rectangle of certain color in certain placewe just make four calls to pygame draw rect(to draw the buttons on the display surface the color object and the rect object we use to position them never changewhich is why we stored them in constant variables like yellow and yellowrect animating the background change def changebackgroundanimation(animationspeed= ) global bgcolor newbgcolor (random randint( )random randint( )random randint( ) newbgsurf pygame surface((windowwidthwindowheight) newbgsurf newbgsurf convert_alpha( rgb newbgcolor for alpha in range( animationspeed)animation loop checkforquit( displaysurf fill(bgcolor newbgsurf fill((rgbalpha)email questions to the authoral@inventwithpython com