How can one move a label around in the hello world example using the on_mouse_motion function?
The docs aren't clicking for me.
How can one move a label around in the hello world example using the on_mouse_motion function?
The docs aren't clicking for me.
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()
Good example, I suggest moving the window.clear() statement to after def on_draw(): to ensure the clock stays visible when the mouse is not moved.