I want to subclass Clock class of pyglet.clock module, but I have some 
troubles when I use schedule_interval:

The following code doesn't print anything and the object c looks like if 
not ticked at all:

#!/usr/bin/env python# -*- coding: utf-8 -*-
import pyglet
class Clock(pyglet.clock.Clock):
    def __init__(self):
        super(Clock, self).__init__()
class Test(object):
    def update(self, dt):
        print dt

w = pyglet.window.Window()@w.eventdef on_draw():
    w.clear()

t = Test()

c = pyglet.clock.Clock()
c.schedule_interval(t.update, 1/60.0)

pyglet.app.run()

But the next works fine.

#!/usr/bin/env python# -*- coding: utf-8 -*-
import pyglet
class Clock(pyglet.clock.Clock):
    def __init__(self):
        super(Clock, self).__init__()

        pyglet.clock.set_default(self)
class Test(object):
    def update(self, dt):
        print dt

w = pyglet.window.Window()@w.eventdef on_draw():
    w.clear()

t = Test()

c = Clock()
c.schedule_interval(t.update, 1/60.0)

pyglet.app.run()

The only difference is the pyglet.clock.set_default(self) sentence in the 
constructor method of Clock.

I think this is not clear or, at least, is not the best way of subclassing 
pyglet.clock.Clock to have your own derived Clock class.

*The questions:*

There is some way to set the default clock automatically with Pyglet?

There is a solution more elegant or pythonic?

Is possible do this without the pyglet.clock.set_default(self) line?

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to