Question about basic use of a timer object from timeit module to execute code every so often in a c

Discussion in 'Python' started by 42zeros@gmail.com, Jul 15, 2005.

  1. Guest

    I would like a function to be executed every x often.
    I was just wondering how to pass the following code correctly. my
    object t just doesn't know what checkMail is. How can I tell it that
    checkMail is a member of the class MyApp?

    thanks in advance,
    code is below


    class MyApp(wx.App):
    def OnInit(self):


    frame = wxMainFrame(None, "thing")
    icon = wx.Icon('foo.bmp', wx.BITMAP_TYPE_ICO)
    frame.SetIcon(icon)
    self.SetTopWindow(frame)

    t = timeit.Timer("checkMail()","30.0")

    t.timeit()
    return True


    def checkMail():

    print "The number of messages is"
    , Jul 15, 2005
    #1
    1. Advertising

  2. Robert Kern Guest

    Re: Question about basic use of a timer object from timeit moduleto execute code every so often in a class

    wrote:
    > I would like a function to be executed every x often.
    > I was just wondering how to pass the following code correctly. my
    > object t just doesn't know what checkMail is. How can I tell it that
    > checkMail is a member of the class MyApp?


    Reread the documentation for timeit. It doesn't do what you think it does.

    Look at wxTimer instead.

    --
    Robert Kern


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
    Robert Kern, Jul 15, 2005
    #2
    1. Advertising

  3. Guest

    Re: Question about basic use of a timer object from timeit module to execute code every so often in a class

    I've seen both documentation for using timeit as simply a timer to
    measure preformance, but also a random page here and there that looked
    to me as if they were using it as a simple timer. HOwever, if there is
    a wxwidget timer I'll gladly hit that up. Thanks for the info
    , Jul 15, 2005
    #3
    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. Miguel Dias Moura
    Replies:
    4
    Views:
    452
    Hans Kesting
    May 6, 2004
  2. Dan Christensen
    Replies:
    4
    Views:
    564
    Peter Otten
    Jul 14, 2004
  3. Dongsheng Ruan
    Replies:
    1
    Views:
    428
    Gabriel Genellina
    Jan 19, 2007
  4. Replies:
    3
    Views:
    331
  5. ssecorp
    Replies:
    5
    Views:
    311
    Steven D'Aprano
    Aug 4, 2008
Loading...

Share This Page