title: Is there a way to have box with text in it along with a text input box?
body: <p>So, I am trying to make a text-based game using pygame, and I am testing out two tutorials. One talks about how I can create a box to hold text, and the other is showing me how to create a text-input box. Now, I am trying to combine these two aspects to create a game that has both, but whenever I try to run it, a window where it runs opens, and then i get a notification saying that the window isn't responding. How can I do this so that then it will run the game properly with both a box forgiven text and a text input box?</p>
  <p>Note: the point of the game is for the user to find errors in the prompts section and type in the right answer, so mistakes in the prompts elements are intentional.</p>
  <pre><code>import pygame
  pygame.init()
  green = (0,255,0)
  blue = (0,0,128)
  white = (255,255,255)
  
  prompts = [&quot;hOW are you doing&quot;, &quot;I writed it using a pencal.&quot;, &quot;My dog ate the bone!.&quot;, &quot;8+1 = 7&quot;, &quot;Please stop!!&quot;, &quot;Here's a challenge; That movie was terribly bad!&quot;, &quot;I go home now meester person.&quot;, &quot;I' d like to stay here.&quot;, &quot;umm...hello?&quot;, &quot;[darn it!!! I think I forget that I am Robin&quot;, &quot;After I sated down I wanted to eating.&quot;, &quot;I can see the Firetruck!?&quot;, &quot;Is the usa a countery.&quot;]
  answers = [&quot;How are you doing?&quot;, &quot;I wrote it using a pencil.&quot;, &quot;My dog ate the bone!&quot;, &quot;8+1 = 9&quot;, &quot;Please stop!!&quot;, &quot;Here's a challenge: That movie was bad!&quot;, &quot;I am going to go home now, mister person.&quot;, &quot;I'd like to stay here.&quot;, &quot;umm...hello?&quot;, &quot;Darn it!!! I think I forgot that I am Robin.&quot;, &quot;After I sat down, I wanted to eat&quot;, &quot;I can see the firetruck!&quot;, &quot;Is the U.S.A a country?&quot;]
  score = 0
  screen = pygame.display.set_mode((640, 480))
  def main():
  
      font = pygame.font.Font(None, 32)
      clock = pygame.time.Clock()
      input_box = pygame.Rect(100, 100, 140, 32)
      color_inactive = pygame.Color('lightskyblue3')
      color_active = pygame.Color('dodgerblue2')
      color = color_inactive
      active = False
      text = ''
      done = False
  
      while not done:
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  done = True
              if event.type == pygame.MOUSEBUTTONDOWN:
                  # If the user clicked on the input_box rect.
                  if input_box.collidepoint(event.pos):
                      # Toggle the active variable.
                      active = not active
                  else:
                      active = False
                  # Change the current color of the input box.
                  color = color_active if active else color_inactive
              if event.type == pygame.KEYDOWN:
                  if active:
                      if event.key == pygame.K_RETURN:
                          print(text)
                          if text == answers[0]:
                              print(&quot;correct!&quot;)
                              del answers[0]
                              del prompts[0]
  
                              text = ''
                          else:
                              print(&quot;wrong&quot;)
                              text = ''
                              del answers[0]
                              del prompts[0]
                      elif event.key == pygame.K_BACKSPACE:
                          text = text[:-1]
                      else:
                          text += event.unicode
  
          screen.fill((30, 30, 30))
          # Render the current text.
          txt_surface = font.render(text, True, color)
          # Resize the box if the text is too long.
          width = max(200, txt_surface.get_width()+10)
          input_box.w = width
          # Blit the text.
          screen.blit(txt_surface, (input_box.x+5, input_box.y+5))
          # Blit the input_box rect.
          pygame.draw.rect(screen, color, input_box, 2)
  
          pygame.display.flip()
          clock.tick(30)
  
  font2 = pygame.font.Font('freesansbold.ttf', 32)
  
  # create a text suface object,
  # on which text is drawn on it.
  text2 = font2.render(prompts[0], True, green, blue)
  
  # create a rectangular object for the
  # text surface object
  textRect = text2.get_rect()
  
  # set the center of the rectangular object.
  textRect.center = (200, 200)
  
  while True:
      screen.fill(white)
  
      screen.blit(text2, textRect)
  
  if __name__ == '__main__':
      pygame.init()
      main()
      pygame.quit()
  </code></pre>