title: How do I stop my page freezing before loading the next screen?
body: <p>Hi working on building a simple little game but for some reason the button that clicks to a different page doesn't seem to be working and I can't figure out where I went wrong. The 2 first buttons work fine, the first one prints yay the second one exits the game but the last one will freeze everything entirely upon clicking. I've changed it to print and it worked fine so there is something in my code that I can't see.</p>
  <p>I essentially just want it to load up some input boxes for user input.</p>
  <p>code for page</p>
  <pre><code>import pygame
  import Test
  import button
  
  pygame.init()
  
  screen = pygame.display.set_mode((800, 600))
  pygame.display.set_caption(&quot;Main Page&quot;)
  icon = pygame.image.load('icons8-robber-32.png')
  pygame.display.set_icon(icon)
  colour_active = pygame.Color('orange')
  colour_inactive = pygame.Color('Yellow')
  font = pygame.font.Font(None, 32)
  
  start_image = pygame.image.load('play.png').convert_alpha()
  exit_image = pygame.image.load('exit.png').convert_alpha()
  menu_image = pygame.image.load('menu.png').convert_alpha()
  
  
  def register():
      input_box1 = Test.inputBox(210, 105, 140, 32)
      input_box2 = Test.inputBox(210, 160, 140, 32)
      input_box3 = Test.inputBox(210, 215, 140, 32)
      input_box4 = Test.inputBox(210, 270, 140, 32)
      input_box5 = Test.inputBox(210, 325, 140, 32)
      input_boxes = [input_box1, input_box2, input_box3, input_box4, input_box5]
      done = False
  
      while not done:
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  done = True
              for box in input_boxes:
                  box.handle_event(event)
  
              for box in input_boxes:
                  box.update()
  
  start_button = button.Button(100, 150, start_image, 0.2)
  exit_button = button.Button(250, 150, exit_image, 0.2)
  menu_button = button.Button(400, 150, menu_image, 0.2)
  
  running = True
  while running:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
  
      screen.fill((150, 255, 100))
      if start_button.draw(screen):
          print('Yay')
      if exit_button.draw(screen):
          running = False
      if menu_button.draw(screen):
          register()
      pygame.display.update()
  
  pygame.quit()
  </code></pre>
  <p>code it's reading from</p>
  <pre><code>import pygame
  
  pygame.init()
  
  colour_active = pygame.Color('orange')
  colour_inactive = pygame.Color('Yellow')
  font = pygame.font.Font(None, 32)
  
  class inputBox():
  
      def __init__(self, x, y, w, h, text=''):
          self.rect = pygame.Rect(x,y,w,h)
          self.color = colour_inactive
          self.text = text
          self.text_surface = font.render(text, True, self.color)
          self.active = False
  
      def handle_event(self,event):
          if event.type == pygame.MOUSEBUTTONDOWN:
              if self.rect.collidepoint(event.pos):
                  self.active = not self.active
              else:
                  self.active = False
  
              self.color = colour_active if self.active else colour_inactive
          if event.type == pygame.KEYDOWN:
              if self.active:
                  if event.key == pygame.K_RETURN:
                      print(self.text)
                  elif event.key == pygame.K_BACKSPACE:
                      self.text = self.text [:-1]
                  else:
                      self.text += event.unicode
                  self.text_surface = font.render(self.text, True, self.color)
  
      def update(self):
          self.rect.w = max(100, self.text_surface.get_width() + 10)
  
      def draw(self, screen):
          screen.blit(self.text_surface, (self.rect.x+5, self.rect.y+5))
          pygame.draw.rect(screen, self.color, self.rect, 2)
  </code></pre>
  <p>thank you!</p>