title: pygame window not responding when clicked
body: <p>I'm using pygame for interface display and controller input on a project I'm working on. Currently everything works sufficiently well so this isn't a major concern, but if it accidentally happens during actual use there might be some problems so I'd like to fix it possible.</p>
  
  <p>When I run my code, the pygame window appears, displays, and updates exactly as expected. However, if I click on it or it gains focus some other way the window freezes and becomes (Not Responding). The code itself continues running, including the thread that is responsible for updating the display, until I close the window so Python itself is still running fine, but the window stops working.</p>
  
  <p>My code for the update loop is here, in all its really ugly glory:</p>
  
  <pre><code>    while(1):
          print "thread is fine"
          pygame.event.pump()
  
          if LOV_Flag == 1:
              videoColor = (255, 0, 0)
          else:
              videoColor = (0, 255, 0)
  
          # Refresh the screen and redraw components
  
          screen.fill((255, 255, 255))
          pulseLabel = pulseFont.render("Pulse: ", 1, (0, 0, 0))
          videoLabel = videoFont.render("Video: ", 1, (0, 0, 0))
          motorsLabel = labelFont.render("Motors", 1, (0, 0, 0))
          motorLabel = captionFont.render("L         R", 1, (0, 0, 0))
          armLabel = captionFont.render("Arm", 1, (0, 0, 0))
          gripperLabel = captionFont.render("Gripper", 1, (0, 0, 0))
          screen.blit(motorsLabel, (55, 50))
          screen.blit(motorLabel, (60, 75))
          screen.blit(pulseLabel, (300, 19))
          screen.blit(videoLabel, (300, 45))
          screen.blit(armLabel, (250, 75))
          screen.blit(gripperLabel, (235, 255))
          leftBar = (50, 200 - drive.getSpeed()[0], 25, drive.getSpeed()[0])
          rightBar = (100, 200 - drive.getSpeed()[1], 25, drive.getSpeed()[1])
          armBar = (250, 200 - (100 * arm.report()), 25, (100 * arm.report()))
          upperArmBar = (250, 200 - (100 * arm.reportUp()), 25, 2) # 100 is the value on the bar
          lowerArmBar = (250, 200 - (100 * arm.reportDown()), 25, 2) # 135 (65) is the value on the bar
          gripperBar = (212, 225, (100 * hand.report()), 25)
          leftGripperBar = (212 + (100 * hand.reportClosed()), 225, 2, 25)
          rightGripperBar = (212 + (100 * hand.reportOpen()), 225, 2, 25)
          pygame.draw.rect(screen, (255, 0, 0), leftBar, 0)
          pygame.draw.rect(screen, (255, 0, 0), rightBar, 0)
          pygame.draw.rect(screen, (255, 0, 0), armBar, 0)
          pygame.draw.rect(screen, (0, 0, 0), upperArmBar, 0)
          pygame.draw.rect(screen, (0, 0, 0), lowerArmBar, 0)
          pygame.draw.rect(screen, (255, 0, 0), gripperBar, 0)
          pygame.draw.rect(screen, (0, 0, 0), leftGripperBar, 0)
          pygame.draw.rect(screen, (0, 0, 0), rightGripperBar, 0)
          pygame.draw.circle(screen, pulseColor, [370, 32], 10)
          pygame.draw.circle(screen, videoColor, [370, 58], 10)
          pygame.display.update()
  
          time.sleep(0.1)
          if killFlag:
              return
  </code></pre>
  
  <p>An <a href="http://puu.sh/faEar/198b61aa52.PNG" rel="nofollow">image</a> for how the window looks, in case that helps you understand the code better.</p>