473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

best way to create a timer


I am wondering what is the best way to create a timer, like an alarm, once it
reaches a time, it triggers an event. I have a way of doing this but it
seems like it isn't good at all. If it helps at all I am using a Tkinter,
but that probably doesn't mean much. The way I was doing it was using a
while loop, and just saying while current time is not = to trigger time, do
nothing, and when it is, do event.
--
View this message in context: http://www.nabble.com/best-way-to-cr...p17815502.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Jun 27 '08 #1
3 1623
You can think of doing with import time module and time.sleep(n) but
you have to calculate n in seconds.
Subhabrata.

Alexnb wrote:
I am wondering what is the best way to create a timer, like an alarm, once it
reaches a time, it triggers an event. I have a way of doing this but it
seems like it isn't good at all. If it helps at all I am using a Tkinter,
but that probably doesn't mean much. The way I was doing it was using a
while loop, and just saying while current time is not = to trigger time, do
nothing, and when it is, do event.
--
View this message in context: http://www.nabble.com/best-way-to-cr...p17815502.html
Sent from the Python - python-list mailing list archive at Nabble.com.
Jun 27 '08 #2
On 13 Giu, 07:42, Alexnb <alexnbr...@gmail.comwrote:
I am wondering what is the best way to create a timer, like an alarm, once it
reaches a time, it triggers an event. I have a way of doing this but it
seems like it isn't good at all. If it helps at all I am using a Tkinter,
but that probably doesn't mean much. The way I was doing it was using a
while loop, and just saying while current time is not = to trigger time, do
nothing, and when it is, do event.
--
View this message in context:http://www.nabble.com/best-way-to-cr...15502p17815502....
Sent from the Python - python-list mailing list archive at Nabble.com.
I think that threading.Timer could be what you're searching for.
--- Giampaolo
http://code.google.com/p/pyftpdlib/
Jun 27 '08 #3
On Jun 12, 11:42 pm, Alexnb <alexnbr...@gmail.comwrote:
I am wondering what is the best way to create a timer, like an alarm, once it
reaches a time, it triggers an event. I have a way of doing this but it
seems like it isn't good at all. If it helps at all I am using a Tkinter,
but that probably doesn't mean much. The way I was doing it was using a
while loop, and just saying while current time is not = to trigger time, do
nothing, and when it is, do event.
Tkinter makes a big difference here. Like most (all?) event loops, it
provides a way to call a function after a specified amount of time.

Here's two pages I found:

http://mail.python.org/pipermail/pyt...st/101233.html
http://www.astro.washington.edu/owen...ary.html#After

Note that it only fires once. If you want it to fire again you're
callback will have to setup another timer.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason Gates | last post by:
Dear all I have written a very complex web app for intranet use. It allows users to search a large database and then returns formatted results. I am currently employing a method as below: 1....
8
by: Rafal M | last post by:
Hi, Is it possible to create timer 9600/s in C? Regards, Rafal
2
by: andrewcw | last post by:
I am trying to do a windows service with C#. I am using as a base the VB.NET article in VS, but I thing the WITHEVENTS timer notation is a delegate. Can anyone provide sample code & anh hints. ...
3
by: jam | last post by:
Dear all, I am wrtiing a console application and doing some test on timer, the below is my sample code I got from some site, but I cannot make it work... Error is 'System.Timers.Timer' does not...
2
by: Ronald S. Cook | last post by:
What is the best way to structure my Windows form so that when it is dragged bigger (i.e. maximized) or smaller, the controls will reorganize themselves "properly"? Assume I have 4 logical...
0
by: juglesh | last post by:
Hello, I've searched and d/l'd but cant seem to find a way of creating a semi-transparent drop shadow for an image. Let me say, be fore I go on, I *do not* want one of those scripts that resizes...
4
by: John | last post by:
I want to write a quick app that will remind me not to slouch at the computer with an Outlook "New Mail Desktop Alert" style pop-up every 15 minutes or so. What I'd like advice on is the best...
10
by: DaTurk | last post by:
Hi, I'm creating an application that will need to use a timer to do a static method call every second. My question, is what would be the best timer to use? I know there are several, but I'd...
4
by: tomer | last post by:
Hi, I'm using vb.net. How can I create timer within aspx page that show the time ? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.