473,583 Members | 3,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1629
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...@gma il.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...@gma il.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
1748
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. Create a global database connection 2. Open a recordset that searches the database 3. Loop through recordset calling the relevant function from an...
8
1636
by: Rafal M | last post by:
Hi, Is it possible to create timer 9600/s in C? Regards, Rafal
2
15685
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. Thanks Andrew
3
7823
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 contain a definition for 'Tick' So what should i do??? the final thing I wanna get is, I have a console will call a exe running in background,...
2
1539
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 sections of controls. Do I create 4 panels and dock them a certain way? I'm just looking for the most normal/best practice.
0
3522
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 your image a bit to the left and bottom, and then grafts a shadow onto it. I want to use a full shadow (it would be about as big as the image) and...
4
1505
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 method of timing and displaying the pop-ups that would have the lowest performance impact for other running applications? Best regards
10
12705
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 like to use a timer that is probably the most reliable, and hopefully designed with high performance in mind. Thank you in advance.
4
442
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
7827
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7936
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8195
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.