tkbx
tkbx

Reputation: 16305

raw_input with limited time?

Is there a way to give the user a raw_input, but give a null response ("") if nothing is typed within x amount of time? I'd like to give the user 10 seconds to enter options when the script starts, but if time expires (or they press enter), simply continue the script. If you know AppleScript, I'd like display dialog "Enter options" giving up after 10 in python

Upvotes: 3

Views: 314

Answers (1)

mayhewr
mayhewr

Reputation: 4021

If you are in unix-land, you can use python's signal library and use an alarm. Otherwise, I think raw_input is totally thread-blocking.

See this answer for implementation help.

Upvotes: 2

Related Questions