You can download this code by clicking the button below.
This code is now available for download.
Creates a Pyglet window and draws a circle inside it. The window can be closed by pressing the ESC key.
Technology Stack : Pyglet
Code Type : Graphics drawing
Code Difficulty : Intermediate
import pyglet
from pyglet.window import key
def create_window_and_draw_circle(x, y, radius, color):
window = pyglet.window.Window()
window.set_size(800, 600)
@window.event
def on_draw():
window.clear()
pyglet.graphics.draw_circle(x, y, radius, color=color)
@window.event
def on_key_press(symbol, modifiers):
if symbol == key.ESCAPE:
window.close()
pyglet.app.run()