Re. threading: As a rule, you shouldn't use sleep() in your main GUI thread because it locks up the GUI. As another rule, only one thread can access any Tkinter components. The standard way to do this sort of thing is to use a background thread to do the timing, and communicate between the main GUI thread and the background thread using a Queue.Queue. There's an example here: http://effbot.org/zone/tki
But there's no need to use threads at all. You can use the after() function to get Tkinter to do the timing for you. See the example here: http://mail.python.org/pip
Main Topics
Browse All Topics





by: ramromPosted on 2005-02-08 at 12:02:16ID: 13257929
Consider:
for i in range(5):
time.sleep(1)
if stop_condition:
break
Or smaller interval and larger loop count if faster resopnse is desired.