Hi, I'll try to answer your questions. 

Yes, pyglet works with python 2 and 3 now. Your example is -ALMOST- 
working, but you missed some very small things. Here is a working example:

import pyglet

window = pyglet.window.Window()
label = pyglet.text.Label('Hello, world', font_name='Times New Roman', 
font_size=36,
                          x=window.width//2, y=window.height//2, )

@window.event
def on_draw():
    window.clear()
    label.draw()

def update(dt):
    label.x += 1

pyglet.clock.schedule_interval(update, 1/60.0)
pyglet.app.run()


Delta time, or "dt", is only about 0.016. The Label x and y values must be 
ints, so doing += doesn't reach the next number. 

Regarding the window event decorators, no, you don't have to use them. You 
could put the window.clear() and label.draw() methods inside your update 
function instead, if you wanted to. 


On Tuesday, November 1, 2016 at 10:05:49 PM UTC+9, [email protected] wrote:
>
> Well, I am quite new for pyglet, I have some questions.
>
> First, is it pyglet works fine on both Python 3 and Python 2 ? I find at 
> least the 'print' state does not work on Python 3, I am afraid there are 
> still big problems I will meet if I run pyglet in Python 3.
>
> Second, is there good pyglet game example for me to learn, I find some in 
> pyweek, but not enough for me. I confused a lot about pyglet, especially 
> some functions do not be called, but worked, some like on_draw (is it the 
> decorater window necessary?), update( where defines the dt ?), I think I 
> need practice.
>
> Third, how to creat a moving label? I have a try, but failed.
>
>
> import pyglet
>
>
> class MyLabel(pyglet.text.Label,pyglet.sprite.Sprite):
>     def __init__(self,text,**kwargs):
>         super(MyLabel,self).__init__(text,**kwargs)
>
> window = pyglet.window.Window()
>
> label = MyLabel('Hello, world',
>                           font_name='Times New Roman',
>                           font_size=36,
>                           x = window.width//2, y = window.height//2)
>
> @window.event
> def on_draw():
>     window.clear()
>     label.draw()
>
> def update(dt):
>     label.x += dt
>     
> pyglet.clock.schedule_interval(update, 1/60.0)
> pyglet.app.run()
>
> so how to creat a moving label?
>

-- 
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 https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to