Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Waiting for some time before executing the next segment of codes in python3.2

I am writing a code to run a gui application(winmerge) and then send some keystrokes to it. I need to wait for some time within the program till the GUI finishes running and then send some keystrokes to it to save the report. How do I implement this? wait() isn't working as after invoking it I can't send keys to the same window.

like image 259
mayank Avatar asked Jun 27 '12 08:06

mayank


People also ask

How do I make Python code wait for some time?

Adding a Python sleep() Call With time.sleep() The time module has a function sleep() that you can use to suspend execution of the calling thread for however many seconds you specify. If you run this code in your console, then you should experience a delay before you can enter a new statement in the REPL.

How do you make Python wait for input before continuing?

Sometimes we want our python program to wait for a specific time before executing the next steps. We can use time module sleep() function to pause our program for specified seconds.

How do you wait for something to finish in Python?

Though there are a plethora of ways to make a pause in Python the most prevalent way is to use the wait() function. The wait() method in Python is used to make a running process wait for another function to complete its execution, such as a child process, before having to return to the parent class or event.

How do you delay a command in Python?

Here is another example where something is run approximately once a minute: import time while True: print("This prints once a minute.") time. sleep(60) # Delay for 1 minute (60 seconds). Save this answer.


1 Answers

from time import sleep
print "hi,"
sleep(5)
print "this is printed 5 seconds later"
like image 57
Mizipzor Avatar answered Sep 27 '22 20:09

Mizipzor