title: How to close GLUT Window when input_raw() is active? Python
body: <p>This might be a silly question, but I couldn't figure this out on my own neither have I find the solution on line. I have a PyOpenGl application that uses GLUT to create its window. The program is supposed to continue running while the user input in the <strong>TERMINAL</strong> is not "quit". Something like this:</p>
  
  <pre><code>command = raw_input()
  while command != "quit":
      if command == "add_shape":
          draw_cube()
      elif command == "remove_shape":
          clear_window()
      elif command == "add_light":
          add_light()
      command = raw_input()
  sys.exit("Application closed by the user")
  </code></pre>
  
  <p>The problem is that when I can <code>raw_input()</code> closing the window using the "x" button doesn't work, only typing quit would terminate the task. At first I thought GLUT would have a callback function for closing window that I could use to detect the "x" button click and force terminate the application, turns out it does have such a function void <code>glutCloseFunc(void(*)(void)callback)</code> but it is not called while <code>raw_input()</code> is active. So what is a good solution for this? How can I read user input from the terminal and still be able to close my application by clicking the "x" button?</p>
  
  <p>REQUIRED:</p>
  
  <ul>
  <li>Read user input from the terminal.</li>
  </ul>
  
  <p>OPTIONAL:</p>
  
  <ul>
  <li>Using GLUT is optional. I've tried with PyGame, but couldn't find a solution to read from the terminal since it only treats interactions with the window.</li>
  </ul>
  
  <p>Thank you!</p>