Why does icon get over written?

Code runs fine, except the icon that I loaded is over written about four second after script starts. The icon is of a black mouse, its of the right size and all that. Whenit displays it is correct, but gets over written. This should not happen. Where is the code that is over writting my icon at?

import pygame
import sys
from pygame.locals import *

pygame.init()

# Constants
FPS = 60
SCREENWIDTH = 400
SCREENHEIGHT = 300
DISPLAYSURFACE = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))

#  functions, modules and classes

while True:  # main game loop
    #  Open first surface
    icon = pygame.image.load('mouse_icon.png')
    pygame.display.set_icon(icon)
    pygame.display.set_caption('Darn Rats!')
    
    # This is where we put the code.

    for event in pygame.event.get():
        #  this is where events go
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        pygame.display.update()

This is quite interesting as the script does nothing but open a window and load the icon and the text.
Thanks.

You’re loading and setting the icon and caption on every iteration of the while loop. If you move that outside the loop, it doesn’t disappear.

That fixed it, thanks. But where did the other icon come from? I figured you would want the main surface to be in the main loop. Learning something all the time.

That’s the default icon. For some reason, sometimes it has a problem with it being set repeatedly (it’s a strange thing to do anyway) and reverts to the default icon.