wx.Timer in wxPython

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbernste
    New Member
    • May 2007
    • 4

    wx.Timer in wxPython

    I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:

    timer = wx.Timer(self, -1)
    self.Bind(wx.EV T_TIMER, self.onTick, timer)
    timer.Start(mil liseconds=1000, oneShot=False)

    where self.onTick(sel f.event) handles the event every second by printing "TICK".

    This works on WindowsXP but not on MacOSX. On MacOSX, onTick() never gets called at all.

    What am I doing wrong??
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by sbernste
    I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:

    timer = wx.Timer(self, -1)
    self.Bind(wx.EV T_TIMER, self.onTick, timer)
    timer.Start(mil liseconds=1000, oneShot=False)

    where self.onTick(sel f.event) handles the event every second by printing "TICK".

    This works on WindowsXP but not on MacOSX. On MacOSX, onTick() never gets called at all.

    What am I doing wrong??
    This should have been posted in the python forum not the cafe. Make sure to post in the correct forum.

    Comment

    • sbernste
      New Member
      • May 2007
      • 4

      #3
      wx.Timer in wxPython

      I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:
      [CODE=python]
      timer = wx.Timer(self, -1)
      self.Bind(wx.EV T_TIMER, self.onTick, timer)
      timer.Start(mil liseconds=1000, oneShot=False)
      [/CODE]
      where self.onTick(sel f.event) handles the event every second by printing "TICK".

      This works on WindowsXP but not on MacOSX. On MacOSX, onTick() never gets called at all.

      What am I doing wrong??

      -- wxNewbie

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by ilikepython
        This should have been posted in the python forum not the cafe. Make sure to post in the correct forum.
        Which explains the double post, so I wont berate the OP for such action. Thank ILP.

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by sbernste
          I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:
          [CODE=python]
          timer = wx.Timer(self, -1)
          self.Bind(wx.EV T_TIMER, self.onTick, timer)
          timer.Start(mil liseconds=1000, oneShot=False)
          [/CODE]
          where self.onTick(sel f.event) handles the event every second by printing "TICK".

          This works on WindowsXP but not on MacOSX. On MacOSX, onTick() never gets called at all.

          What am I doing wrong??

          -- wxNewbie
          As for you, sbernste, we'll teach you about [ code ] tags as we go along.
          Timers are a bit of a mystery. I've never been able to find anyone who could tell by why a 50mS wxTimer should only run 16 times a second on one machine out of 4 that I tried my code on. The wxTimers are completely OS dependant, so I guess the only question that I have for you is "What's your wxPython version on the Mac?".

          Comment

          • sbernste
            New Member
            • May 2007
            • 4

            #6
            Originally posted by bartonc
            As for you, sbernste, we'll teach you about [ code ] tags as we go along.
            Timers are a bit of a mystery. I've never been able to find anyone who could tell by why a 50mS wxTimer should only run 16 times a second on one machine out of 4 that I tried my code on. The wxTimers are completely OS dependant, so I guess the only question that I have for you is "What's your wxPython version on the Mac?".
            (1) What are code tags?

            (2) I am running wxPython version 2.8.4.0 (mac-ansi) under MacOsX darwin.

            (3) I have implemented a work-around by running a loop in a separate thread that calls time.sleep(1) and fires off a custom wxPython event. But I'd still rather use wxTimer if at all possible.

            Comment

            • bartonc
              Recognized Expert Expert
              • Sep 2006
              • 6478

              #7
              Originally posted by sbernste
              (1) What are code tags?
              It's all right there, on the right hand side of the page when POSTING or REPLYing: 4 little things to keep in mind in * GUIDELINES...

              (2) I am running wxPython version 2.8.4.0 (mac-ansi) under MacOsX darwin.
              I just got a Mac (kind of old, but it was free - OS X 10.1.5). I may have to start playing with it soon. I'm on a HUGE project at the moment.

              (3) I have implemented a work-around by running a loop in a separate thread that calls time.sleep(1) and fires off a custom wxPython event. But I'd still rather use wxTimer if at all possible.
              Nice work-around...
              I remember reading that if the system is short on timer resources, the wxTimer objects would not run. Perhaps that's the case here. Or perhaps there's a compatability issue with that OS. It's always worth trying the latest version.

              Good luck...

              Comment

              Working...