Sorry for the bad title, if you think of a better one please tell me.
So I was asked to make a button that says a line from a video game. I attempted to have the while loop add 1 to a variable every time it looped through, then display the variable in the caption of the window. I did this so that I could see if it was looping, and really, what was going on. It showed a rapidly increasing number, then froze the computer (I had to restart the computer). I tried putting a short wait in the loop, still would not respond. I am also having this exact same problem in a much longer and more complex program that I'm working on, so if I figure it out, it will solve both issues. Don't just give me code, please tell me why I need to use it or what it does. Here's the program:
from pygame import *
import pygame
pygame.init()
pygame.display.set_caption('Potato')
screen = pygame.display.set_mode((224, 224))
button = pygame.image.load("C:/Python34/redbutton.jpg")
screen.blit(button,(0,0))
pygame.display.flip()
potato = pygame.mixer.Sound("C:/Python34/potato.wav")
test = 0
pressed = False
while pressed == False:
if pygame.mouse.get_pressed()[1]:
pressed = True
if pygame.mouse.get_pressed()[0]:
potato.play()
sys.exit()