Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Timer

0 views
Skip to first unread message

Sam Bull

unread,
Mar 17, 2010, 4:43:38 AM3/17/10
to pytho...@python.org
I'm writing a pyGTK program, and I need to display the contents of a
window for a few seconds before automatically moving on. I have tried
using the time.sleep method, but this has problems, such as the program
becoming unresponsive.

I have now attempted to use a timer, but this does not seem to run the
function at the end of the time. The code of my latest attempt:

def next(self=None, testnum=10, testspeed=5):
self.count += 1
#Sets label, telling the user the next word to memorise
self.nobtns.set_markup("Word %s is: %s" % (self.count,
self.words[self.count-1]))
self.nobtns.show()
if self.count == testnum: #When all words are shown
self.nobtns.hide()
else:
self.timer = threading.Timer(testspeed, self.next, [testnum,
testspeed])
self.timer.start()

Putting a print statement at the beginning of the function, I can see
that the function is not being run by the timer. Any help on getting
this working would be appreciated.

Thanks,
Sam Bull

signature.asc

Peter Otten

unread,
Mar 17, 2010, 5:16:17 AM3/17/10
to
Sam Bull wrote:

GUI toolkits usually have their own way of handling timeouts. I don't know
pygtk, but the following looks promising:

http://www.pygtk.org/pygtk2tutorial/ch-TimeoutsIOAndIdleFunctions.html

Peter

0 new messages