Usage of timers in a pyglet

Discussion about user contributed plugins

Moderator: Moderator

mydani
Posts: 58
Joined: Wed Oct 31, 2007 4:04 pm

Usage of timers in a pyglet

Postby mydani » Sat Sep 27, 2008 9:51 am

Hi,

I'm currently trying to call a function periodically using a timer...
unfortunately, the timer does not seem to work and mms will hang after I left the pyglet.
The timer should print some text on the screen but it's only done once.

Code: Select all

      
      # set state update timer
      self.t = threading.Timer(1, self.updateStateDisplay)
      self.t.start()
      
...
   def updateStateDisplay(self):
      ....


Anyone knows about how to have a time based event in a pyglet?Thanks!

Regards,
Daniel

Fredde
veteran
Posts: 288
Joined: Tue Dec 06, 2005 7:18 am
Location: Sweden

Re: Usage of timers in a pyglet

Postby Fredde » Sat Sep 27, 2008 8:12 pm

mydani wrote:Hi,
...
The timer should print some text on the screen but it's only done once.

Code: Select all

      
      # set state update timer
      self.t = threading.Timer(1, self.updateStateDisplay)
      self.t.start()
      
...
   def updateStateDisplay(self):
      ....

...

The python Timer class will only run the given function once after the time has passed (1 second in your case), it will not repeat.
mydani wrote:...
unfortunately, the timer does not seem to work and mms will hang after I left the pyglet.
...

This doesn't sound good, mms should not hang :?
Could you show the code in method updateStateDisplay? Maybe that could give me a hint.


Return to “user plugins”

Who is online

Users browsing this forum: No registered users and 2 guests