How to use on_mouse_motion to move around a lable via pyglet?
How can one move a label around in the hello wor开发者_JAVA百科ld example using the on_mouse_motion function?
The docs aren't clicking for me.
on_mouse-motion
hello_world_example.py
Figured it out: Don't know if this is the most efficient solution though.
EDIT -> fixed for just xy.
#!/usr/bin/env python
import pyglet
window = pyglet.window.Window()
fps_display = pyglet.clock.ClockDisplay()
label = pyglet.text.Label('Hello World!',font_name='Arial',font_size=36, x=0, y=0)
@window.event
def on_mouse_motion(x, y, dx, dy):
window.clear()
label.x = x
label.y = y
fps_display = pyglet.clock.ClockDisplay()
@window.event
def on_draw():
fps_display.draw()
label.draw()
pyglet.app.run()
精彩评论