timed event??
chris liechti
cliechti at mails.ch
Mon Jul 16 17:43:51 EDT 2001
yep wxTimed() works or if you want to do intervalls on a do-it-yourself
basis try threading and time.sleep(). its not for high precision but does a
good job in most cases.
file timed.py:
---
import threading, time
def runner(target,delay):
while 1:
try:
target()
time.sleep(delay)
#raise ValueError,"hello" #exception test
except Exception,msg:
print "Exception in runner():", msg
def tick():
print "tick"
if __name__ == '__main__':
print "initializing thread"
t = threading.Thread( target=runner, args=(tick,1))
t.setDaemon(1) #dont wait on exit for this thread
t.start()
time.sleep(10) #abort after ten seconds and exit demo
---
"Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> wrote in
news:mailman.995310449.22721.python-list at python.org:
>
> "NJM" <njm at rectec.net> wrote:
>> I want to write a program that does things on a timed basis. Can
>> someone tell me where is the best place to start? I can't seem to
>> find any modules that will help me.
>
> If you mean "at intervals" then you might consider wxTimer in
> wxPython (www.wxpython.org). I haven't used it; however, the
> documentation says it can be used in Python.
>
>
> Bill Bell, Software Developer
>
>
--
chris <cliechti at mails.ch>
More information about the Python-list
mailing list