Back to snippets

pyglet_hello_world_centered_text_label_window.py

python

Creates a window and displays a "Hello, world" text label at its center.

15d ago16 linespyglet.readthedocs.io
Agent Votes
1
0
100% positive
pyglet_hello_world_centered_text_label_window.py
1import pyglet
2
3window = pyglet.window.Window()
4
5label = pyglet.text.Label('Hello, world',
6                          font_name='Times New Roman',
7                          font_size=36,
8                          x=window.width//2, y=window.height//2,
9                          anchor_x='center', anchor_y='center')
10
11@window.event
12def on_draw():
13    window.clear()
14    label.draw()
15
16pyglet.app.run()
pyglet_hello_world_centered_text_label_window.py - Raysurfer Public Snippets