title: python curses dynamic value + user input
body: <p>I'm a bit new to python and curses, so had a few questions. I'm making a terminal application that uses curses to generate the ui. I am trying to make something similar to the linux program <strong>top</strong> except it fetches data from an xml file. I have this code that i am modifying from a previous stackoverflow question. To simplify things the dynamic value i'm updating here is just the time. My two questions are as follows:</p>
  
  <ol>
  <li>I have <code>x = screen.getch(7,2)</code> to check if the user wants to quit. Similar to top, if the user can type "q" to quit. However because of this the time values arent being updated. How can I have user input as well the dynamic updating of the values. When I comment out the screen.getch the values start updating. Ive read that <strong>top</strong> is using the C version of curses so this should be possible, just need a help in the right direction.</li>
  <li>My second question is about the refresh rate. Is there a way to control it using the curses api? The easy way I thought to do it was using the <code>time.sleep()</code> command but I wasnt sure if this was the right way to go about it? Ideally I'd like to update this with new xml data every 60 seconds or so.  </li>
  </ol>
  
  <p>I did see this <a href="https://stackoverflow.com/questions/26152942/python-curses-user-input-while-updating-screen">Python/curses user input while updating screen</a> in stackoverflow and i think question is similar but i was a bit overwhelmed by the code. i dont really understand classes yet and couldnt follow the logic. i was looking for something simple. I believe the guy ended up using <code>line = sys.stdin.read(1)</code> to get his code running. I didnt have any luck when using this instead of getch. I got some error about x not being able to use strip().</p>
  
  <pre><code>from os import system
  import curses
  import time
  
  x = 0
  
  while x != ord('q'):
      screen = curses.initscr()
      curses.curs_set(False) 
      screen.clear()
      screen.border(0)
      screen.addstr(1, 2, "BLAH BLAH ",
                curses.A_REVERSE)
  
      ltime = time.asctime(time.localtime(time.time()))
  
      screen.addstr(3, 2,'BLAH1: ' + ltime)    
      screen.addstr(4, 2, "BLAH2")
  
      screen.refresh()
  
      x = screen.getch(7,2)
  
  
  curses.endwin()
  </code></pre>