Un esempio sarà il seguente:import simplegui
import random
larghezza = 300
altezza = 200
raggio = 15
x = larghezza / 2
y = altezza / 2
vx = random.randrange(1,5)
vy = random.randrange(1,5)
def disegno (pannello):
global x, y, vx, vy
pannello.draw_circle((x,y), raggio, 2, "Yellow", "#ffffc0")
x += vx
y += vy
if x < raggio or x > larghezza - raggio:
vx = -vx
if y < raggio or y > altezza - raggio:
vy = -vy
finestra = simplegui.create_frame("Prova", larghezza, altezza, 5)
finestra.set_canvas_background('#000080')
finestra.set_draw_handler(disegno)
finestra.start()