-1

I've been trying to display five numbers from 0 to 4 every second each.

import pyglet
import time

window = pyglet.window.Window()

@window.event
def on_draw():
    for n in range(0,5):
        window.clear()
        label = pyglet.text.Label(str(n),font_name='Times New Roman',font_size=72,x=window.width//2, y=window.height//2,anchor_x='center', anchor_y='center')
        label.draw()
        print(n)
        time.sleep(1)

pyglet.app.run()

It does not run into any error although it's a blank screen for a few seconds and after that it shows only number four.

1 Answers1

0

I would start with the docs and look at the simple text example.

https://pyglet.readthedocs.io/en/latest/programming_guide/text.html

on_draw is not being used correctly.

Then for scheduling changes every 1 second, look at the clock scheduling examples.

https://pyglet.readthedocs.io/en/latest/modules/clock.html#scheduling

Charlie
  • 680
  • 4
  • 11