I'm trying to create a python script that will do a load of computation while continually updating a curses interface (for the purposes of this question, just imagine it's a progress bar). The code is structured like this:
while notDone:
compute()
updateScreen()
I'd like to allow the user to hit a button to quit the program, but the only way I know how with curses is like this:
while notDone:
compute()
updateScreen()
c = screen.getch()
if c == "q": break
Which won't work, because it means that after each iteration, the script will wait for the user to press a key. I need the keypress to work like Ctrl+C does in most python scripts - it interrupts the script and kills it. In fact, a way to just capture a KeyboardInterrupt exception and handle it like normal would work just fine.