Can I set up a timed callback without Tkinter or twisted or something?

Discussion in 'Python' started by Hendrik van Rooyen, Oct 14, 2006.

  1. Hi,

    I want to do the equivalent of the after thingy in tkinter - setting up in
    effect a timed call back.

    My use case is as a "supervisory" timer - I want to set up an alarm, which I
    want to cancel if the expected occurrence occurs - but its not a GUI app.

    My googling gets a lot of stuff pointing to optparse...

    Does the standard lib have anything like this?

    - Hendrik
    Hendrik van Rooyen, Oct 14, 2006
    #1
    1. Advertising

  2. Hendrik van Rooyen

    hg Guest

    Hendrik van Rooyen wrote:
    > Hi,
    >
    > I want to do the equivalent of the after thingy in tkinter - setting up in
    > effect a timed call back.
    >
    > My use case is as a "supervisory" timer - I want to set up an alarm, which I
    > want to cancel if the expected occurrence occurs - but its not a GUI app.
    >
    > My googling gets a lot of stuff pointing to optparse...
    >
    > Does the standard lib have anything like this?
    >
    > - Hendrik
    >


    http://python.active-venture.com/lib/timer-objects.html
    hg, Oct 14, 2006
    #2
    1. Advertising

  3. Hendrik van Rooyen wrote:
    > I want to do the equivalent of the after thingy in tkinter - setting up in
    > effect a timed call back.
    >
    > My use case is as a "supervisory" timer - I want to set up an alarm, which I
    > want to cancel if the expected occurrence occurs - but its not a GUI app.


    Use a thread that uses something like:
    def action():
    sleep(50)
    if not canceled:
    callback(foo)
    as its action.

    The callback ill be in another thread, but .... Look up threading for
    more details.


    --Scott David Daniels
    Scott David Daniels, Oct 14, 2006
    #3
  4. Re: Can I set up a timed callback without Tkinter or twistedorsomething?

    "Scott David Daniels" <> wrote:


    > Hendrik van Rooyen wrote:
    > > I want to do the equivalent of the after thingy in tkinter - setting up in
    > > effect a timed call back.
    > >
    > > My use case is as a "supervisory" timer - I want to set up an alarm, which I
    > > want to cancel if the expected occurrence occurs - but its not a GUI app.

    >
    > Use a thread that uses something like:
    > def action():
    > sleep(50)
    > if not canceled:
    > callback(foo)
    > as its action.
    >
    > The callback ill be in another thread, but .... Look up threading for
    > more details.


    Thanks - I was hoping that I did not have to do it myself - the Tkinter thingy
    works nicely - I was hoping that the interpreter could handle something like
    this... What I don't like too much about the sleep based solution is that yer
    blind and deaf while sleeping - at least in that thread - and I am trying for
    fairly fine grained timing resolution...

    is there not something based on signals? - I seem to recall some such thing
    here in another thread.. ( I am running Linux)

    -Hendrik
    Hendrik van Rooyen, Oct 15, 2006
    #4
  5. Re: Can I set up a timed callback without Tkinter or twistedorsomething?

    "hg" <> wrote:


    > Hendrik van Rooyen wrote:
    > > Hi,
    > >
    > > I want to do the equivalent of the after thingy in tkinter - setting up in
    > > effect a timed call back.
    > >
    > > My use case is as a "supervisory" timer - I want to set up an alarm, which I
    > > want to cancel if the expected occurrence occurs - but its not a GUI app.
    > >
    > > My googling gets a lot of stuff pointing to optparse...
    > >
    > > Does the standard lib have anything like this?
    > >
    > > - Hendrik
    > >

    >
    > http://python.active-venture.com/lib/timer-objects.html
    >

    Thanks - will check it out - Hendrik
    Hendrik van Rooyen, Oct 15, 2006
    #5
  6. Hendrik van Rooyen

    Guest

    Re: Can I set up a timed callback without Tkinter or twistedorsomething?

    Hendrik> is there not something based on signals? - I seem to recall
    Hendrik> some such thing here in another thread.. ( I am running Linux)

    Have you tried:

    import signal
    help(signal)

    at the interpreter prompt?

    Skip
    , Oct 15, 2006
    #6
  7. Re: Can I set up a timed callback without Tkinter or twistedorsomething?

    <> wrote:

    >
    > Hendrik> is there not something based on signals? - I seem to recall
    > Hendrik> some such thing here in another thread.. ( I am running Linux)
    >
    > Have you tried:
    >
    > import signal
    > help(signal)
    >
    > at the interpreter prompt?
    >
    > Skip


    *blush* - actually, no - I was looking for signals...

    - Hendrik
    Hendrik van Rooyen, Oct 17, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,330
    Steve
    Jul 1, 2003
  2. Christian Seberino
    Replies:
    1
    Views:
    725
    Andrew Bennetts
    Apr 13, 2004
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    444
    Jean-Paul Calderone
    Jun 17, 2008
  4. Glyph
    Replies:
    0
    Views:
    173
    Glyph
    Dec 27, 2012
  5. Glyph
    Replies:
    0
    Views:
    150
    Glyph
    Apr 3, 2013
Loading...

Share This Page