By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,932 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,932 IT Pros & Developers. It's quick & easy.

wx.Timer in wxPython

P: 4
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.EVT_TIMER, self.onTick, timer)
timer.Start(milliseconds=1000, oneShot=False)

where self.onTick(self.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??
May 29 '07 #1
Share this Question
Share on Google+
6 Replies


ilikepython
Expert 100+
P: 844
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.EVT_TIMER, self.onTick, timer)
timer.Start(milliseconds=1000, oneShot=False)

where self.onTick(self.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.
May 29 '07 #2

P: 4
I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:
Expand|Select|Wrap|Line Numbers
  1. timer = wx.Timer(self, -1)
  2. self.Bind(wx.EVT_TIMER, self.onTick, timer)
  3. timer.Start(milliseconds=1000, oneShot=False)
  4.  
where self.onTick(self.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
May 29 '07 #3

bartonc
Expert 5K+
P: 6,596
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.
May 30 '07 #4

bartonc
Expert 5K+
P: 6,596
I am using wx.Timer to update a clock on a wxPython display. The relevant lines of code look like this:
Expand|Select|Wrap|Line Numbers
  1. timer = wx.Timer(self, -1)
  2. self.Bind(wx.EVT_TIMER, self.onTick, timer)
  3. timer.Start(milliseconds=1000, oneShot=False)
  4.  
where self.onTick(self.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?".
May 30 '07 #5

P: 4
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.
May 30 '07 #6

bartonc
Expert 5K+
P: 6,596
(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...
May 30 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.