I am trying to write code which will let the user press a key like 'b' and run an operation, while a script is still running, and have the script continue afterwards. How can I do this??? I am using Linux.
how can I change what a script does while it is running, by pressing a key
Collapse
X
-
Tags: None
-
In a basic setup, something like
Of course if you want to be a little fancier, you can put the raw_input into a loop and test whether the input is valid before continuing.Code:userAnswer=raw_input("Press 'b' or hit enter") if userAnswer=="b": #do whatever elif userAnswer=="": #do something else else: #do the default option
If you want to do it like an application, then you need to get into the various GUIs. tkinter is pretty standard.
Comment