Timer

Sam Bull sam at sambull.co.uk
Wed Mar 17 04:43:38 EDT 2010


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20100317/ded60641/attachment.sig>


More information about the Python-list mailing list