Results 1 to 3 of 3

Thread: Python timer?

  1. #1
    Join Date
    Mar 2005
    Location
    Austin
    Beans
    339
    Distro
    Ubuntu 7.04 Feisty Fawn

    Python timer?

    Hi

    I am creating a mail notification applet, and I have done pretty well so far, i have made the app get new mesages and display a notification but have to way to set this to a timer, so it polls the mail server x numner of seconds

    Does anyone have any suggestions on how to do this?

    Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    Australia
    Beans
    418
    Distro
    The Feisty Fawn Testing

    Re: Python timer?

    Assuming you're using PyGTK:

    Code:
    import gobject
    
    gobject.timeout_add (60 * 1000, function, ...)
    
    def function (...):
        #do stuff here
        return False
    That will cause function() to get run in (about) a minutes time, being 60000 miliseconds. Returning False make it not run again, and the function will get run in another minute if you return True.

    See http://www.pygtk.org/pygtk2reference...t--timeout-add for more info.

  3. #3
    Join Date
    Oct 2004
    Beans
    369
    Distro
    Gutsy Gibbon Testing

    Re: Python timer?

    Pygame also has a time class: http://www.pygame.org/docs/ref/time.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •