Re: [Tutor] Making a function run every second.

2011-11-29 Thread Alan Gauld
On 29/11/11 14:54, Mic wrote: I want a function to run every second , how do I do that? Say that the function look like this: def hi(): print("hi") The answer depends on whether you want to do it in a GUI or in a command line program. Since your other posts have included GUI code I'd sugg

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
On 11/29/2011 11:09 AM, Dave Angel wrote: On 11/29/2011 10:52 AM, Mic wrote: Okay, I undestand. Hmm, what is a drift? I just noticed I hadn't answered that one. It doesn't matter any more since you're running tkinter. But for completeness: If you had a non-event driven program (eg. a con

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Wayne Werner
On Tue, Nov 29, 2011 at 10:09 AM, Dave Angel wrote: > tkinter provides a couple of specific timer events, and I now see > your reply to a message that said to use the after() method, which is a > one-shot. I believe there's another one that sets a periodic timer so you > don't have to do an afte

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
On 11/29/2011 10:52 AM, Mic wrote: -Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:33 PM -Original Message- From: "Mic" Sender: tutor-bounces+bodsda=googlemail@python.org Date: Tue, 29 Nov 2011 15:54:59 To: Subject: [Tutor] Making a function

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
ge: 3 Date: Tue, 29 Nov 2011 10:33:41 -0500 From: Dave Angel To: bod...@googlemail.com Cc: Tutor - python List , Mic Subject: Re: [Tutor] Making a function run every second. Message-ID: <4ed4fb55.1000...@davea.name> Content-Type: text/plain; charset=windows-1252; format=flowed (You put yo

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
-Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:33 PM To: bod...@googlemail.com Cc: Mic ; Tutor - python List Subject: Re: [Tutor] Making a function run every second. (You put your response in the wrong place; it belongs after the part you're qu

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
-Ursprungligt meddelande- From: bod...@googlemail.com Sent: Tuesday, November 29, 2011 4:19 PM To: Mic ; tutor-bounces+bodsda=googlemail@python.org ; Tutor - python List Subject: Re: [Tutor] Making a function run every second. You won't get it exactly on because the ti

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
(You put your response in the wrong place; it belongs after the part you're quoting.) he On 11/29/2011 10:19 AM, bod...@googlemail.com wrote: You won't get it exactly on because the time it takes to call the function will affect your trigger time. I would use something like an infinite loop w

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Peter Otten
Mic wrote: > I want a function to run every second , how do I do that? > > Say that the function look like this: > > def hi(): > print("hi") For a console app you could use a for-loop with time.sleep() or http://docs.python.org/dev/py3k/library/sched.html For a script that uses tkinter the

Re: [Tutor] Making a function run every second.

2011-11-29 Thread bodsda
You won't get it exactly on because the time it takes to call the function will affect your trigger time. I would use something like an infinite loop with a 1 second sleep after the function call Bodsda Sent from my BlackBerry® wireless device -Original Message- From: "Mic" Sender: t

Re: [Tutor] Making a function run every second.

2011-11-29 Thread delegbede
In my opinion, you probably have to think of how many times it has to run. If you want to run forever, you can just make an infinite loop. Here's my try. import time def myloop(): while True: print 'Hi' time.sleep(1) This would run forever and print H