"Olrik Lenstra" <[EMAIL PROTECTED]> wrote

   def onScan(self, event):
      self.myfile = open('foo.txt')
      self.count = 0
      self.setTimer(0.01, self.processLine)

Ah, I got this mixed up. I thought this was a function built into python.
So I would need to define setTimer in the MyClass too.
Is there anything that I can read on timers?

The wx documentation on timers is OK. Here is a very short
example program

import wx

class Counter(wx.Window):
  def __init__(self,  interval=1000):  # default of 1 second
      self.count = 0
      self.t = wx.Timer(self)
      self.Bind(wx.EVT_TIMER, self.onTimer, self.t)
      self.t.Start(interval, oneShot = True)

  def onTimer(self, evt):
      self.upDate()
      self.t.Start(-1, oneShot=True)

  def upDate(self):
     self.count += 1
     print "Called by timer event ", self.count

class App(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None)
        Counter(self)

p = wx.PySimpleApp()
f = App()
f.Show()
p.mainloop()


Note this is untested since I don't have wx installed on this PC,
but it should be close. You can also use Start(delay, oneShot=False)
to create a continuously firing timer.

HTH,

Alan G

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to