Regarding LOC the shortest answer i could come up with:
from threading import Thread
import gobject
gobject.threads_init()
time_to_wait = 2.0 # time in seconds
nonblocking_wait = Thread(target=sleep, args=(timetowait,))
nonblocking_wait.start()
while nonblocking_wait.is_alive():
nonblocking_wait.join(.05)
gtk.main_iteration_do(True) # blocks if no event is pending
On a second glance i realized, that for some readers the relevance of the sleep-thread might be obscure. It's purpose is to establish a maximum timelimit of time_to_wait
+ 0.05
seconds (+ overhead)! you could do it with a counter or similar approaches, but this way you prevent an useless load on the cpu in idle loops.
This way gtk can still handle draw-updates.
any progressbar-updates or whatever must be placed into the while loop.