0

Is there a way to set up my script so that with one push button I can quit() my script? I am trying to fix my script but because I use input simulation I can't do control-D or using mouse clicks.

Thanks!

1

1 Answer 1

0

Try this:

>>> try:
...     a = raw_input()
... except EOFError:
...     print "Exited"
... 
Exited
>>> 

Use EOFError for control-D, KeyboardInterrupt for control-C.

Sign up to request clarification or add additional context in comments.

2 Comments

I am not sure I understand; wouldn't that work only when the script runs to that point? I am looking for a way to, with one push of a button, terminate a running script, while the script runs in background or when I do whatever else.
I heard you can "use a thread to listen in the background" ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.