   [Python] Redraw blank screen help
  I am trying to get n to redraw a blank white screen but it will not work.import pygamepygame.init()def main():screen = pygame.display.set_mode((640,480))pygame.display.set_caption("Draw Lines Program")bg = pygame.Surface(screen.get_size())bg.convert()bg.fill((255,255,255))clock = pygame.time.Clock()run = Truewhile run:clock.tick(30)for event in pygame.event.get():if event.type == pygame.QUIT:run = Falseelif event.type == pygame.MOUSEBUTTONDOWN:MouseD = pygame.mouse.get_pos()elif event.type == pygame.MOUSEBUTTONUP:MouseU = pygame.mouse.get_pos()pygame.draw.line(bg, (0,0,0), MouseD, MouseU, 3)elif event.type == pygame.KEYDOWN:if event.key == pygame.K_f:pygame.image.save(bg, "pic1.bmp")elif event.key == pygame.K_n:screen.blit(bg, (0,0))screen.blit(bg, (0,0))pygame.display.flip()if __name__ == "__main__":main()
  The code you are using to "draw a blank white screen" for the N key is the same as the code you use unconditionally each time through the loop to refresh the current screen state: screen.blit(bg, (0,0)). It should be no surprise that the N key therefore fails to do anything visible. It also shouldn't have been hard to pick up on this, seeing as those two lines of source code come one right after the other (whitespace and indentation notwithstanding).Since 'bg' will be blitted to screen regardless, what the N key should do is cause 'bg' to become a blank white screen. The way to do this is the same way that you do it before the loop starts: bg.fill((255,255,255)).   